DataGrip 2024.3 Help

Share code with GitLab snippets

Enable the Git plugin

This functionality relies on the Git plugin, which is bundled and enabled in DataGrip by default. If the relevant features are not available, make sure that you did not disable the plugin.

  1. Press Ctrl+Alt+S to open settings and then select Plugins.

  2. Open the Installed tab, find the Git plugin, and select the checkbox next to the plugin name.

Install the GitLab plugin

This functionality relies on the GitLab plugin, which you need to install and enable.

  1. Press Ctrl+Alt+S to open settings and then select Plugins.

  2. Open the Marketplace tab, find the GitLab plugin, and click Install (restart the IDE if prompted).

Use GitLab snippets to store and quickly share bits of code, files, or entire folders with others.

Create a snippet

  1. Select a code fragment in the editor, or files and folders you want to include to the new snippet in the Files tool window Alt+2.

  2. Right-click the selection to open the context menu and then select Create Snippet.

    The Create a GitLab Snippet dialog opens.

    A dialog with a list of options to create a GitLab snippet
  3. Specify the Project parameter:

    • If you want to create a project snippet, choose a project from the list of available GitLab projects you can create your snippet for.

      To make this snippet listed under the chosen project, but visible only to you, keep the Private box checked.

    • If you want to create a personal snippet, choose None.

  4. Add a title and, optionally, a description of the new snippet.

  5. Specify the Path handling mode parameter to prevent duplication when passing the name of each file in the snippet to GitLab:

    • Relative: to find the nearest common parent of the selected files and pass along the paths to the files relative to that common parent.

    • Content root relative: to include the path of the files relative to the module.

    • Project relative: to include the path of the files relative to the project.

    • No paths: to pass along the filenames only, without a path.

  6. Select the Private checkbox to make this snippet visible only to you.

  7. Select the Copy URL checkbox to copy the link to the new snippet once it is created.

  8. Select the Open in browser checkbox to open the new snippet in a default browser once the snippet is created.

  9. Click OK.

Last modified: 22 November 2024