Merge request approvals All tiers All offerings
You can configure your merge requests so that they must be approved before they can be merged. While GitLab Free allows all users with Developer or greater permissions to approve merge requests, these approvals are optional. GitLab Premium and GitLab Ultimate provide additional flexibility:
- Create required rules about the number and type of approvers before work can merge.
- Specify a list of users who act as code owners for specific files, and require their approval before work can merge.
You can configure merge request approvals on a per-project basis, and some approvals can be configured on the group level. Support for group-level settings for merge request approval rules is tracked in this epic. Administrators of GitLab Premium and GitLab Ultimate self-managed GitLab instances can also configure approvals for the entire instance.
How approvals work
With merge request approval rules, you can set the minimum number of required approvals before work can merge into your project. You can also extend these rules to define what types of users can approve work. Some examples of rules you can create include:
- Users with specific permissions can always approve work.
- Code owners can approve work for files they own.
- Users with specific permissions can approve work, even if they don’t have merge rights to the repository.
- Users with specific permissions can be allowed or denied the ability to override approval rules on a specific merge request.
You can also configure:
- Additional settings for merge request approvals for more control of the level of oversight and security your project needs.
- Merge request approval rules and settings through the GitLab UI or with the Merge request approvals API.
Approve a merge request
When an eligible approver visits an open merge request, GitLab displays one of these buttons after the body of the merge request:
- Approve: The merge request doesn’t yet have the required number of approvals.
- Approve additionally: The merge request has the required number of approvals.
- Revoke approval: The user viewing the merge request has already approved the merge request.
Eligible approvers can also use the /approve
quick action when adding a comment to
a merge request. In GitLab 13.10 and later,
if a user approves a merge request and is shown in the reviewer list, a green check mark
() displays next to their name.
After a merge request receives the number and type of approvals you configure, it can merge unless it’s blocked for another reason. Merge requests can be blocked by other problems, such as merge conflicts, unresolved threads, or a failed CI/CD pipeline.
To prevent merge request authors from approving their own merge requests, enable Prevent author approval in your project’s settings.
If you enable approval rule overrides, merge requests created before a change to default approval rules are not affected. The only exceptions are changes to the target branch of the rule.
Optional approvals
Introduced in GitLab 13.2.
GitLab allows all users with Developer or greater permissions to approve merge requests. Approvals in GitLab Free are optional, and don’t prevent a merge request from merging without approval.
Required approvals Premium All offerings
Moved to GitLab Premium in 13.9.
Required approvals enforce code reviews by the number and type of users you specify. Without the approvals, the work cannot merge. Required approvals enable multiple use cases:
- Enforce review of all code that gets merged into a repository.
- Specify reviewers for a given proposed code change, and a minimum number of reviewers, through Approval rules.
- Specify categories of reviewers, such as backend, frontend, quality assurance, or database, for all proposed code changes.
- Use the code owners of changed files, to determine who should review the work.
- Require an approval before merging code that causes test coverage to decline.
- Users on GitLab Ultimate can also require approval from a security team before merging code that could introduce a vulnerability.
Invalid rules
- Introduced in GitLab 15.1.
-
Changed in GitLab 15.11 with a flag named
invalid_scan_result_policy_prevents_merge
. Disabled by default. -
Generally available in GitLab 16.2. Feature flag
invalid_scan_result_policy_prevents_merge
removed.
invalid_scan_result_policy_prevents_merge
.Whenever an approval rule cannot be satisfied, the rule is displayed as Auto approved. This applies to the following conditions:
- The only eligible approver is the author of the merge request.
- No eligible approvers (either groups or users) have been assigned to the approval rule.
- The number of required approvals is more than the number of eligible approvers.
These rules are automatically approved to unblock their respective merge requests, unless they were created through a scan result policy. Invalid approval rules created through a scan result policy are presented with Action required and are not automatically approved, blocking their respective merge requests.
Related topics
- Merge request approvals API
- Instance-level approval rules for self-managed installations