Getting started with merge requests (FREE)

A merge request (MR) is the basis of GitLab as a tool for code collaboration and version control.

When working in a Git-based platform, you can use branching strategies to collaborate on code.

A repository is composed by its default branch, which contains the major version of the codebase, from which you create minor branches, also called feature branches, to propose changes to the codebase without introducing them directly into the major version of the codebase.

Branching is especially important when collaborating with others, avoiding changes to be pushed directly to the default branch without prior reviews, tests, and approvals.

When you create a new feature branch, change the files, and push it to GitLab, you have the option to create a merge request, which is essentially a request to merge one branch into another.

The branch you added your changes into is called source branch while the branch you request to merge your changes into is called target branch.

The target branch can be the default or any other branch, depending on the branching strategies you choose.

In a merge request, beyond visualizing the differences between the original content and your proposed changes, you can execute a significant number of tasks before concluding your work and merging the merge request.

You can watch our GitLab Flow video for a quick overview of working with merge requests.

How to create a merge request

Learn the various ways to create a merge request.

What you can do with merge requests

When you start a new merge request, you can immediately include the following options. You can also add them later by either selecting Edit on the merge request's page at the top-right side, or by using keyboard shortcuts for merge requests:

After you have created the merge request, you can also:

Many of these options can be set:

See also other features associated to merge requests.


WARNING: Requesting a code review is an important part of contributing code. However, deciding who should review your code and asking for a review are no easy tasks. Using the "assignee" field for both authors and reviewers makes it hard for others to determine who's doing what on a merge request.

The merge request Reviewers feature enables you to request a review of your work, and see the status of the review. Reviewers help distinguish the roles of the users involved in the merge request. In comparison to an Assignee, who is directly responsible for creating or merging a merge request, a Reviewer is a team member who may only be involved in one aspect of the merge request, such as a peer review.

To request a review of a merge request, expand the Reviewers select box in the right-hand sidebar. Search for the users you want to request a review from. When selected, GitLab creates a to-do list item for each reviewer.

To learn more, read Review a merge request.

Merge requests to close issues

To create a merge request to close an issue when it's merged, you can either:

  • Add a note in the MR description.

  • In the issue, select Create a merge request. Then, you can either:

    • Create a new branch and a draft merge request in one action. The branch is named issuenumber-title by default, but you can choose any name, and GitLab verifies that it's not already in use. The merge request inherits the milestone and labels of the issue, and is set to automatically close the issue when it is merged.
    • Create a new branch only, with its name starting with the issue number.

If the issue is confidential, you may want to use a different workflow for merge requests for confidential issues to prevent confidential information from being exposed.

Deleting the source branch

When creating a merge request, select the Delete source branch when merge request accepted option, and the source branch is deleted when the merge request is merged. To make this option enabled by default for all new merge requests, enable it in the project's settings.

This option is also visible in an existing merge request next to the merge request button and can be selected or cleared before merging. It is only visible to users with the Maintainer role in the source project.

If the user viewing the merge request does not have the correct permissions to delete the source branch and the source branch is set for deletion, the merge request widget displays the Deletes source branch text.

Delete source branch status

Recommendations and best practices for merge requests

  • When working locally in your branch, add multiple commits and only push when you're done, so GitLab runs only one pipeline for all the commits pushed at once. By doing so, you save CI/CD minutes.
  • Delete feature branches on merge or after merging them to keep your repository clean.
  • Take one thing at a time and ship the smallest changes possible. By doing so, reviews are faster and your changes are less prone to errors.
  • Do not use capital letters nor special chars in branch names.