Merge requests allow you to visualize and collaborate on the proposed changes to source code that exist as commits on a given Git branch.
A Merge Request (MR) is the basis of GitLab as a code collaboration and version control platform. It's exactly as the name implies: a request to merge one branch into another.
A. Consider you're a software developer working in a team:
- You checkout a new branch, and submit your changes through a merge request
- You gather feedback from your team
- You work on the implementation optimizing code with Code Quality reports (STARTER)
- You verify your changes with JUnit test reports in GitLab CI/CD
- You avoid using dependencies whose license is not compatible with your project with License Compliance reports (ULTIMATE)
- You request the approval from your manager (STARTER)
- Your manager:
- Your changes get deployed to production with manual actions for GitLab CI/CD
- Your implementations were successfully shipped to your customer
B. Consider you're a web developer writing a webpage for your company's website:
- You checkout a new branch, and submit a new page through a merge request
- You gather feedback from your reviewers
- Your changes are previewed with Review Apps
- You request your web designers for their implementation
- You request the approval from your manager (STARTER)
- Once approved, your merge request is squashed and merged, and deployed to staging with GitLab Pages
- Your production team cherry picks the merge commit into production
Merge requests (aka "MRs") display a great deal of information about the changes proposed. The body of an MR contains its description, along with its widget (displaying information about CI/CD pipelines, when present), followed by the discussion threads of the people collaborating with that MR.
MRs also contain navigation tabs from which you can see the discussion happening on the thread, the list of commits, the list of pipelines and jobs, the code changes, and inline code reviews.
To get started, read the introduction to merge requests.
Merge request navigation tabs at the top
Introduced in GitLab 12.6. This positioning is experimental.
So far, the navigation tabs present in merge requests to display Discussion, Commits, Pipelines, and Changes were located after the merge request widget.
To facilitate this navigation without having to scroll up and down through the page to find these tabs, based on user feedback, we're experimenting with a new positioning of these tabs. They are now located at the top of the merge request, with a new Overview tab, containing the description of the merge request followed by the widget. Next to Overview, you can find Pipelines, Commits, and Changes.
Please note this change is currently behind a feature flag which is enabled by default. For self-managed instances, it can be disabled through the Rails console by a GitLab administrator with the following command:
Creating merge requests
Reviewing and managing merge requests
See the features at your disposal to review and manage merge requests.
Testing and reports in merge requests
GitLab has the ability to test the changes included in a merge request, and can display or link to useful information directly in the merge request page:
|Accessibility Testing||Automatically report A11y violations for changed pages in merge requests|
|Browser Performance Testing (PREMIUM)||Quickly determine the performance impact of pending code changes.|
|Code Quality (STARTER)||Analyze your source code quality using the Code Climate analyzer and show the Code Climate report right in the merge request widget area.|
|Display arbitrary job artifacts||Configure CI pipelines with the
|GitLab CI/CD||Build, test, and deploy your code in a per-branch basis with built-in CI/CD.|
|JUnit test reports||Configure your CI jobs to use JUnit test reports, and let GitLab display a report on the merge request so that it’s easier and faster to identify the failure without having to check the entire job log.|
|License Compliance (ULTIMATE)||Manage the licenses of your dependencies.|
|Metrics Reports (PREMIUM)||Display the Metrics Report on the merge request so that it's fast and easy to identify changes to important metrics.|
|Multi-Project pipelines (PREMIUM)||When you set up GitLab CI/CD across multiple projects, you can visualize the entire pipeline, including all cross-project interdependencies.|
|Pipelines for merge requests||Customize a specific pipeline structure for merge requests in order to speed the cycle up by running only important jobs.|
|Pipeline Graphs||View the status of pipelines within the merge request, including the deployment process.|
|Test Coverage visualization||See test coverage results for merge requests, within the file diff.|
Security Reports (ULTIMATE)
In addition to the reports listed above, GitLab can do many types of Security reports, generated by scanning and reporting any vulnerabilities found in your project:
|Container Scanning||Analyze your Docker images for known vulnerabilities.|
|Dynamic Application Security Testing (DAST)||Analyze your running web applications for known vulnerabilities.|
|Dependency Scanning||Analyze your dependencies for known vulnerabilities.|
|Static Application Security Testing (SAST)||Analyze your source code for known vulnerabilities.|
Authorization for merge requests
There are two main ways to have a merge request flow with GitLab:
- Working with protected branches in a single repository
- Working with forks of an authoritative project