doc/user/project/merge_requests/_index.md
{{< details >}}
{{< /details >}}
{{< history >}}
moved_mr_sidebar removed.{{< /history >}}
Merge requests provide a central location for your team to review code, have discussions, and track code changes. To help describe why a change was made, link a merge request to an issue and automatically close the issue when the merge request merges.
Merge requests help ensure subject matter experts review your proposed changes and your organization's security requirements are met. When you create your merge request early in the development process, your team has time to catch bugs and code quality problems.
When viewing a merge request, you see:
Learn the various ways to create a merge request.
When you create a merge request, GitLab checks for the existence of a description template to add data to your merge request. GitLab checks these locations in order from 1 to 5, and applies the first template found to your merge request:
| Name | Project UI
setting | Group
default.md | Instance
default.md | Project
default.md | No template |
|:-----|:---------------------:|:---------------------:|:------------------------:|:-----------------------:|:-----------:|
| Standard commit message | 1 | 2 | 3 | 4 | 5 |
| Commit message with an issue closing pattern like Closes #1234 | 1 | 2 | 3 | 4 | 5 * |
| Branch name prefixed with an issue ID, like 1234-example | 1 * | 2 * | 3 * | 4 * | 5 * |
[!note] Items marked with an asterisk (*) also append an issue closing pattern.
You can view merge requests for your project, group, or yourself.
{{< tabs >}}
{{< tab title="You're participating in" >}}
To view all merge requests on the homepage, use the <kbd>Shift</kbd>+<kbd>m</kbd> keyboard shortcut, or:
or:
{{< /tab >}}
{{< tab title="For a project" >}}
To view all merge requests for a project:
Or, to use a keyboard shortcut, press <kbd>g</kbd>+<kbd>m</kbd>.
{{< /tab >}}
{{< tab title="For all projects in a group" >}}
To view merge requests for all projects in a group:
If your group contains subgroups, this view also displays merge requests from the subgroup projects.
{{< /tab >}}
{{< tab title="For a file" >}}
When viewing a file in your repository, GitLab shows a badge with the number of open merge requests that target the current branch and modify the file. This helps you identify files that have pending changes.
The availability of this feature is controlled by a feature flag. For more information, see view open merge requests for a file.
To view the open merge requests for a file:
{{< /tab >}}
{{< /tabs >}}
{{< history >}}
source branch introduced in GitLab 16.6.merged by introduced in GitLab 16.9. Available only when the feature flag mr_merge_user_filter is enabled.merged by generally available in GitLab 17.0. Feature flag mr_merge_user_filter removed.merged before and merged after introduced in GitLab 18.6.{{< /history >}}
To filter the list of merge requests:
#30 to return only merge request 30.=: Is!=: Is notAND.To filter merge requests by deployment data, such as the environment or a date, you can type (or select from the dropdown list) the following:
[!note] Projects using a fast-forward merge method do not return results, as this method does not create a merge commit.
When filtering by an environment, a dropdown list presents all environments that you can choose from.
When filtering by Deployed before or Deployed after:
YYYY-MM-DD. Wrap them in double quotes (")
if you want to specify both a date and time ("YYYY-MM-DD HH:MM").If you have permission to add changes to a merge request, you can add your changes to an existing merge request in several ways. These ways depend on the complexity of your change, and whether you need access to a development environment:
To assign the merge request to a user, use the /assign @user quick action in a text area in
a merge request, or:
In the top bar, select Search or go to and find your project.
In the left sidebar, select Code > Merge requests and find your merge request.
In the right sidebar, expand the right sidebar and locate the Assignees section.
Select Edit.
Search for the user you want to assign, and select the user. GitLab Free allows one assignee per merge request, but GitLab Premium and GitLab Ultimate allow multiple assignees:
GitLab adds the merge request to the user's Assigned merge requests page.
Participants are users who interacted with a merge request. For information about viewing participants, see participants.
During the merge request review process, reviewers provide feedback on your changes. When a reviewer is satisfied with the changes, they can enable auto-merge, even if some merge checks are failing. After all merge checks pass, the merge request is automatically merged, without further action from you.
Default merge permissions:
main, is protected.To determine if you have permission to merge a specific merge request, GitLab checks:
If you decide to permanently stop work on a merge request, close it rather than deleting it.
Prerequisites:
To close merge requests in the project:
GitLab closes the merge request, but preserves records of the merge request, its comments, and any associated pipelines.
You can delete the source branch for a merge request:
An administrator can make this option the default in the project's settings.
The delete-branch action is performed by the user who sets auto-merge, or merges the merge request. If the user lacks the correct role, such as in a forked project, the source branch deletion fails.
{{< details >}}
{{< /details >}}
Merge requests are often chained together, with one merge request depending on
the code added or changed in another merge request. To support keeping individual
merge requests small, GitLab can update up to four open merge requests when their
target branch merges into main. For example:
feature-alpha into main.feature-beta into feature-alpha.If these merge requests are open at the same time, and merge request 1 (feature-alpha)
merges into main, GitLab updates the destination of merge request 2 from feature-alpha
to main.
Merge requests with interconnected content updates are usually handled in one of these ways:
main first. Merge request 2 is then
retargeted to main.feature-alpha. The updated merge request 1, which
now contains the contents of feature-alpha and feature-beta, merges into main.This feature works only when a merge request is merged. Selecting Remove source branch after merging does not retarget open merge requests. This improvement is proposed as a follow-up.
For a software developer working in a team:
For a web developer writing a webpage for your company's website:
{{< history >}}
mr_activity_filters enabled on GitLab.com in GitLab 16.0.mr_activity_filters removed.{{< /history >}}
To understand the history of a merge request, filter its activity feed to show you only the items that are relevant to you.
In the top bar, select Search or go to and find your project.
In the left sidebar, select Code > Merge requests.
Select a merge request.
Scroll to Activity.
On the right side of the page, select Activity filter to show the filter options. If you've already selected filter options, this field shows a summary of your choices, like Activity + 5 more.
Select the types of activity you want to see. Options include:
Optional. Select Sort ({{< icon name="sort-lowest" >}}) to reverse the sort order.
Your selection persists across all merge requests. You can also change the sort order by clicking the sort button on the right.
Discussions in a merge request include single comments, and threads of comments. Open (unresolved) threads block the merge of a merge request, but single comments do not. When a thread's discussion is finished, resolve the thread to collapse its display. If a comment thread is important but should not block the merge request, move it to an issue to continue the discussion.
GitLab shows the number of open threads in the upper-right corner of a merge request. This merge request has three open threads:
To see all comments in the collapsed threads, expand the threads:
To move open threads to a new issue, and unblock a merge request:
{{< tabs >}}
{{< tab title="Move one thread" >}}
If you have one specific open thread in a merge request, you can create an issue to resolve it separately:
GitLab marks the thread as resolved, and adds a link from the merge request to the newly created issue.
{{< /tab >}}
{{< tab title="Move all open threads" >}}
If you have multiple open threads in a merge request, you can create an issue to resolve them separately:
GitLab marks all threads as resolved, and adds a link from the merge request to the newly created issue.
{{< /tab >}}
{{< /tabs >}}
You can prevent merge requests from merging while threads remain open. When you enable this setting, the Open threads counter in a merge request is shown in orange while at least one thread remains open.
You can set merge requests to automatically resolve threads when a new push changes the lines they describe.
Threads are now resolved if a push makes a diff section outdated. Threads on lines that don't change and top-level resolvable threads are not resolved.
{{< details >}}
{{< /details >}}
{{< history >}}
notifications_todos_buttons. Disabled by default.{{< /history >}}
[!flag] The availability of this feature is controlled by a feature flag. For more information, see the history.
Enabling this feature flag moves the notifications and to-do item buttons to the upper-right corner of the page.