Work with GitLab merge requests
Using GitLab merge requests, you can incorporate changes from a source branch to a target branch.
Create a merge request
In the main menu, go to
.In the Merge Requests tool window that opens, click Create Merge Request in the top-right corner.
A new tab opens with a merge request draft.
Click the name of the base repository on the left and specify the branch that will receive the updates.
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.
If you have a project that uses multiple remote repositories, you can change the head repository in this popup as well.
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.
Click Create Merge Request.
Manage incoming merge requests
To view incoming merge requests, click in the tool window bar on the left.
Alternatively, go to
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 CLion.
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.
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.
In the main menu, go to
.In the list of merge requests, select the one you want to work with and double-click it.
CLion opens an overview of the selected merge request.
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.
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.
Click the branch with incoming changes and choose Checkout 'branch name' in the context menu to start the review mode.
Select the file you want to investigate, right-click it and select Jump to Source F4 from the context menu.
In the file that opens, pink markers in the gutter indicate the changes and the comments that are available for review.
Clicking the comment icons in the gutter will hide and open the comments.
Clicking the pink markers reveals a popup displaying the original code.
Hover over the gutter and click to leave a comment.
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.
To place a high-level comment on a merge request as a whole, open the timeline view of this merge request.
Click Submit Review in the merge request details tab to submit the review or approve the merge request.
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 CLion.
In the main menu, go to
or click in the tool window bar on the left.Select the merge request from the list and double-click it. CLion opens an overview of the selected merge request.
Double-click a file to view the suggested changes.
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.
In the main menu, go to
.In the list of merge requests, select the one you want to work with and double-click it.
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 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.