merge_merge_request
Merges a reviewed GitLab merge request after checks pass, with options to squash commits, auto-merge when pipeline succeeds, or remove the source branch.
Instructions
Merge a merge request. Use this only after checking the merge request approval, conflict, and pipeline state; use approve_merge_request to approve rather than merge. The operation changes repository state and may squash commits, schedule auto-merge, or delete the source branch, so it requires merge permission and returns GitLab's merge result or a mergeability error. Pass sha from get_merge_request (sha or diff_refs.head_sha); GitLab 19.2+ groups may reject merges without it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sha | No | SHA of the source-branch HEAD from get_merge_request (`sha` or `diff_refs.head_sha`). If provided, GitLab merges only when HEAD still matches. GitLab 19.2+ groups may require this (Require a commit SHA on the merge requests API). | |
| squash | No | Squash commits into a single commit when merging | |
| auto_merge | No | If true, the merge request merges when the pipeline succeeds. | |
| project_id | Yes | Project ID or complete URL-encoded path to project | |
| merge_request_iid | No | The IID of a merge request | |
| merge_commit_message | No | Custom merge commit message | |
| squash_commit_message | No | Custom squash commit message | |
| should_remove_source_branch | No | Remove source branch after merge | |
| merge_when_pipeline_succeeds | No | If true, the merge request merges when the pipeline succeeds. Deprecated in GitLab 17.11. Use `auto_merge` instead. |