DataGrip 2024.3 Help

Work with GitLab merge requests

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).

Using GitLab merge requests, you can incorporate changes from a source branch to a target branch.

Create a merge request

  1. In the main menu, go to Git | GitLab | View Merge Requests.

  2. In the Merge Requests tool window that opens, click Plus Create Merge Request in the top-right corner.

    A new tab opens with a merge request draft.

    Merge Requests tool window with a new merge request
  3. Click the name of the base repository on the left and specify the branch that will receive the updates.

    Base repository
  4. Click the name of the head repository on the right and specify the branch with the changes that will be added to the base repository.

    Head repository

    If you have a project that uses multiple remote repositories, you can change the head repository in this popup as well.

  5. Specify the name for your merge request in the Title field, and, optionally, provide a description of the changes to be applied through your request and add reviewers.

  6. Click Create Merge Request.

Manage incoming merge requests

To view incoming merge requests, click GitLab icon in the tool window bar on the left.

Merge requests filters

Alternatively, go to Git | GitLab | Show GitLab Merge Requests in the main menu.

Use the Merge Requests tool window to:

  • Review merge requests: browse code, check the diff between the suggested changes and the base revision, and leave comments directly from DataGrip.

  • Filter requests by state, author, assignee, reviewer, and label.

  • Jump to a merge request on GitLab: right-click a merge request and choose Open Merge Request on GitLab from the context menu.

  • Create a local branch based on incoming changes: open a merge request, click the branch with incoming changes, and choose Checkout 'branch name' in the context menu.

  • Investigate branch-related changes in the Log tab of the Git tool window: open a merge request, click the branch with incoming changes, and choose Show 'branch name' in Git Log in the context menu.

    This will help you navigate the code related to this merge request, make sure the project builds and the tests pass.

  • Resolve merge conflicts: if the branch in an incoming merge request has merge conflicts, you can resolve them right from the Merge Requests tool window either by creating a merge commit from the target branch or by rebasing onto the target branch.

    Option to resolve merge conflicts

To make sure you always have the latest information about the merge requests, press Ctrl+F5. Alternatively, right-click the necessary merge request and select Refresh List.

Give feedback to a merge request

When there are changes that require your attention, a white dot marks the GitLab tool window and the unseen merge requests are marked with blue dots.

  1. In the main menu, go to Git | GitLab |View Merge Requests.

  2. In the list of merge requests, select the one you want to work with and double-click it.

    DataGrip opens an overview of the selected merge request.

    Merge Request overview
    • Next to the title, there is a merge request number. Click it if you want to open the merge request on GitLab.

    • Click the View Timeline button to open the merge request timeline.

    • If a merge request consists of several commits, focus on a specific one by selecting it in the Changes from drop-down menu. Navigate between commits by pressing the up and down buttons.

      Choose commit to investigate
    • Right-click any file to open the context menu for this file.

    • In case a reviewer has left any comments or suggestions, there is a counter with the number of comments in the list of files.

      Commented files in the Merge Requests tool window
  3. Click the branch with incoming changes and choose Checkout 'branch name' in the context menu to start the review mode.

    Checkout branch with incoming changes
  4. Double-click the file that you want to investigate.

  5. In the diff viewer that opens, hover over the gutter and click to leave a comment.

    Comment field with a suggestion
    • Select Add Comment to post a comment immediately and get other reviewers notified.

    • Select Save as draft to add multiple comments.

      Before you submit your review, your comments are marked Pending, and you can edit or delete them.

  6. To place a high-level comment on a merge request as a whole, open the timeline view of this merge request.

  7. Click Submit Review in the merge request details tab to submit the review or approve the merge request.

    Submit review dialog

    Select one of the possible outcomes:

    • Approve: to approve merging changes.

    • Submit: to submit your feedback without an approval.

    If you change your mind, you can later click the Revoke Approval button.

If the work with the merge request is done, you can merge or close it in the same merge request details tab.

Work with comments in your merge request

If someone left comments to your merge request, you can resolve them or leave your answers directly in DataGrip.

  1. In the main menu, go to Git | GitLab | View Merge Requests or click GitLab icon in the tool window bar on the left.

  2. Select the merge request from the list and double-click it. DataGrip opens an overview of the selected merge request.

  3. Double-click a file to view the suggested changes.

  4. You can resolve a comment, reply to it, or leave your reaction.

After you finished working on the merge request, you can re-request review, merge, or close it in the same merge request details tab.

Merge or close a merge request

After submitting your review and solving all the issues, you can merge or close the merge request.

  1. In the main menu, go to Git | GitLab | View Merge Requests.

  2. In the list of merge requests, select the one you want to work with and double-click it.

  3. At the bottom of the overview, there is a button with merge options that differ depending on the stage of the review process.

    • If you have approved the updates after your review, you can merge the merge request by clicking Merge.

      For more merge options, click the Down arrow and select Squash and Merge to squash the commits with your changes into one before merging them.

    • Click More and select Request Review if you need another opinion on this merge request or Close Merge Request if you do not want to merge it.

Last modified: 11 November 2024