Merge requests are the primary method of making changes to files in a GitLab project. Create and submit a merge request to propose changes. Your team leaves comments on your merge request, and makes Code Suggestions you can accept from the user interface. When your work is reviewed, your team members can choose to accept or reject it. Show
You can review merge requests from the GitLab interface. If you install the GitLab Workflow VS Code extension, you can also review merge requests in Visual Studio Code. For an overview, see Merge request review. GitLab Duo Suggested ReviewersHistory
GitLab uses machine learning to suggest reviewers for your merge request. For an overview, see GitLab Duo Suggested Reviewers. To suggest reviewers, GitLab uses:
GitLab Duo Suggested Reviewers also integrates with Code Owners, profile status, and merge request rules, helping you make a more informed decision when choosing reviewers that can meet your review criteria. For more information, see Data usage in GitLab Duo Suggested Reviewers. Enable Suggested ReviewersProject Maintainers or Owners can enable Suggested Reviewers by visiting the project settings. Enabling Suggested Reviewers triggers GitLab to create an ML model for your project that is used to generate reviewers. The larger your project, the longer this process can take. Usually, the model is ready to generate suggestions within a few hours. No action is required after the feature is enabled. After the model is ready, recommendations populate the Reviewer dropdown list in the right-hand sidebar of a merge request with new commits. Review a merge requestWhen you review a merge request, you can create comments that are visible only to you. When you’re ready, you can publish them together in a single action. To start your review:
If you and are shown in the reviewer list, a green check mark displays next to your name. Request a reviewTo assign a reviewer to a merge request, in a text area in the merge request, use the
3 . Alternatively:
The merge request is added to the user’s review requests. From multiple usersHistory
To assign multiple reviewers to a merge request, in a text area in the merge request, use the
3 . Alternatively:
To remove a reviewer, clear the user from the same dropdown list. Download merge request changes as a diffTo download the changes included in a merge request as a diff:
If you know the URL of the merge request, you can also download the diff from the command line by appending
5 to the URL. This example downloads the diff for merge request
6:
To download and apply the diff in a one-line CLI command:
Download merge request changes as a patch fileTo download the changes included in a merge request as a patch file:
If you know the URL of the merge request, you can also download the patch from the command line by appending
7 to the URL. This example downloads the patch file for merge request
6:
To download and apply the patch in a one-line CLI command using
9:
Submit a reviewYou can submit your completed review in multiple ways:
When you submit your review, GitLab:
Review comments can also resolve or unresolve . To resolve or unresolve a thread when replying to a comment:
Pending comments display information about the action to be taken when the comment is published:
If you have a review in progress, you can also add a comment from the Overview tab by selecting Add to review: Approval Rule information for ReviewersWhen editing the Reviewers field in a new or existing merge request, GitLab displays the name of the matching approval rule below the name of each reviewer. Code Owners are displayed as
1 without group detail. This example shows reviewers and approval rules when creating a new merge request: This example shows reviewers and approval rules in a merge request sidebar: Request a new reviewAfter a reviewer completes their merge request reviews, the author of the merge request can request a new review from the reviewer:
GitLab creates a new to-do item for the reviewer, and sends them a notification email. When commenting on a diff, you can select which lines of code your comment refers to by either:
Multiline comments display the comment’s line numbers above the body of the comment: Bulk edit merge requests at the project levelUsers with at least the Developer role can manage merge requests. When bulk-editing merge requests in a project, you can edit the following attributes:
To update multiple project merge requests at the same time:
Bulk edit merge requests at the group levelUsers with at least the Developer role can manage merge requests. When bulk editing merge requests in a group, you can edit the following attributes:
To update multiple group merge requests at the same time:
Associated featuresThese features are associated with merge requests:
TroubleshootingSometimes things don’t go as expected in a merge request. Here are some troubleshooting steps. Merge request cannot retrieve the pipeline statusThis can occur if Sidekiq doesn’t pick up the changes fast enough. SidekiqSidekiq didn’t process the CI state change fast enough. Wait a few seconds and the status should update automatically. BugMerge request pipeline statuses can’t be retrieved when the following occurs:
To enable the pipeline status to be properly retrieved, close and reopen the merge request again. TipsHere are some tips to help you be more efficient with merge requests in the command line. Copy the branch name for local checkoutThe merge request sidebar contains the branch reference for the source branch used to contribute changes for this merge request. To copy the branch reference into your clipboard, select the Copy branch name button () in the right sidebar. Use it to check out the branch locally from the command line by running
2. Checkout merge requests locally through the
0 ref History
A merge request contains all the history from a repository, plus the additional commits added to the branch associated with the merge request. Here’s a few ways to check out a merge request locally. You can check out a merge request locally even if the source project is a fork (even a private fork) of the target project. This relies on the merge request
0 ref (
In GitLab 16.6 and later, the merge request
0 ref is deleted 14 days after a merge request is closed or merged. The merge request is then no longer available for local checkout from the merge request
0 ref anymore. The merge request can still be re-opened. If the merge request’s branch exists, you can still check out the branch, as it isn’t affected. Checkout locally by adding a Git aliasAdd the following alias to your
1:
Now you can check out a particular merge request from any repository and any remote. For example, to check out the merge request with ID 5 as shown in GitLab from the
2 remote, do: This fetches the merge request into a local
3 branch and check it out. Checkout locally by modifying
1 for a given repository Locate the section for your GitLab remote in the
1 file. It looks like this:
You can open the file with: Now add the following line to the above section:
In the end, it should look like this:
Now you can fetch all the merge requests:
And to check out a particular merge request:
All the above can be done with the
6 script. Cached merge request countIn a group, the sidebar displays the total count of open merge requests. This value is cached if it’s greater than than 1000. The cached value is rounded to thousands (or millions) and updated every 24 hours. How do I request a review again on GitHub?Click their team name or username to request a review. After your pull request is reviewed and you've made the necessary changes, you can ask a reviewer to re-review your pull request. Navigate to Reviewers in the right sidebar and click next to the reviewer's name whose review you'd like. What happens when you decline a pull request?Once you decline a pull request, you'll have to open a new pull request request to review code for the same branch. Declining a pull request has no impact on the source or destination branches of the pull request. What happens when you dismiss a review in GitHub?If a pull request has changed since it was reviewed and the person who requested changes isn't available to give an approving review, repository administrators or people with write access can dismiss a review. This changes the status of the review to a review comment. How do I request more than one reviewer on GitHub?At the top of the team page, click Settings. In the left sidebar, click Code review. Select Enable auto assignment. Under "How many team members should be assigned to review?", select the dropdown menu and choose a number of reviewers to be assigned to each pull request. |