GitLab: why the merge was refused
When a merge through the API fails, GitLab answers with one of five statuses, and each means something different. From GitLab's merge API, checked against its source (lib/api/merge_requests.rb): 405 means that a merge check stops the merge request right now, 409 that the source branch moved, 422 that the merge itself failed, 401 that your account may not merge into the target branch, and 400 that the group or instance requires the commit SHA.
The answers
- 405
{"message":"405 Method Not Allowed"}: the merge request cannot be merged now. Something in its merge checks stops it; see below. - 409
SHA does not match HEAD of source branch: …: the request named the commit the reviewer saw, and the source branch has another head now (GitLab adds the new one after the colon). Someone pushed after you looked. - 422
Branch cannot be merged: GitLab tried and the merge did not happen. In the source, this is when the merge request turns out not to be mergeable at the last moment, or the merge service did not merge it. - 401
401 Unauthorized: in this endpoint, not a bad token. GitLab checks whether your account may update the target branch (can_be_merged_by?), so, for example, a protected branch that your role may not merge into answers 401. - 400
SHA must be provided when merging: the group or instance setting require a commit SHA on the merge requests API is on, and the request did not name one.
To see why GitLab will not merge, before you try: Merge Request (MR) Review Inbox for GitLab, a plugin for JetBrains IDEs, shows the merge checks from detailed_merge_status with the blocking ones first, and says for each refusal which case it is.
Which merge check stops it (405)
Read the merge request and look at detailed_merge_status:
curl -H "PRIVATE-TOKEN: your-token" "https://gitlab.com/api/v4/projects/group%2Fproject/merge_requests/42"
Some of its values, from GitLab's merge status list:
draft_status: it is a draft. Mark it as ready.not_approved: approvals are still required.requested_changes: a reviewer requested changes.discussions_not_resolved: all threads must be resolved first.ci_must_passorci_still_running: the pipeline must succeed first.conflict: the source and target branches conflict.need_rebase: the source branch must be rebased onto the target. When GitLab finds that an open merge request with commits now conflicts, and its source branch still exists, it emails the author and, if someone set it to auto-merge, that person,Merge request !42 can no longer be merged due to conflict., and adds a to-do for them (GitLab's merge_request.rb and merge_request_unmergeable_email.text.haml).not_open: it is not open, so reopen it first. From GitLab 19.3, when the source or target branch is gone, reopening it on the page leaves it closed and showsCannot reopen this merge request because the source or target branch no longer exists.The API answers 422 with that sentence inmessageand leaves out the other changes of the same request. Restore the branch, or open a new merge request (GitLab's merge_request.rb and reopen_service.rb, merge request !245864). Up to 19.2, the Reopen button of a closed merge request showed onlyAn error occurred. Unable to reopen this merge request.whatever the reason, and it still does when the answer has no message (GitLab's mr_widget_closed.vue).merge_request_blocked: another merge request must be merged first.checking,uncheckedorpreparing: GitLab has not finished checking. The check runs in the background, so read it again a moment later.
The list also has statuses for status checks, security policies, locked files and paths, a required Jira issue and a title pattern. Asking to merge automatically (auto_merge) instead merges it once the checks pass; it has a 405 of its own, see what auto-merge waits for.
On the merge request page the same checks are listed under Merge blocked: 1 check failed or Merge blocked: 3 checks failed, one line each (GitLab's constants.js):
- Draft and approvals:
Merge request must not be draft.(draft_status),All required approvals must be given.(not_approved),Change requests must be approved by the requesting user.(requested_changes),The merge request approvals are currently syncing.(approvals_syncing). - Threads:
Open threads must be resolved.(discussions_not_resolved). - Pipelines and checks:
Pipeline must succeed.(ci_must_pass),Status checks must pass.(status_checks_must_pass),All policy rules must be satisfied.(security_policy_violations),When security policies are enforced, all pipelines for the latest commit must succeed before merge.(security_policy_pipeline_check). - Branches:
Merge conflicts must be resolved.(conflict),Fast forward merge is not possible. Please rebase.(need_rebase; with a merge train it endsPlease rebase or use merge train.),Source branch exists and contains commits.(commits_status),Merge request must be open.(not_open),Merge request dependencies must be merged.(merge_request_blocked). - Other rules:
Either the title or description must reference a Jira issue.(jira_association_missing),Title must match required pattern(title_regex),All paths must be unlocked(locked_paths),All LFS files must be unlocked.(locked_lfs_files),Cannot merge outside the merge schedule.(merge_time). - Nothing failing:
Ready to merge!, or, for someone who may not merge,Ready to merge by members who can write to the target branch.While GitLab is still checking:Checking if merge request can be merged…,Checking for merge conflicts.andChecking if a fast-forward merge is possible.
When the merge itself fails
Some checks run only after you select Merge. GitLab then keeps the reason on the merge request, and the widget shows it in a red box with Try again. added, for example:
Branch has been updated since the merge was requested. Please review the changes. Try again.
The API returns the reason in the merge_error field of the merge request. The reasons, in the order GitLab checks them:
You are not allowed to merge this merge request: your role may not merge into the target branch.This merge request cannot be merged, because this repository has exceeded the allocated storage for your project: the target project is over its repository size limit. A message about full namespace storage is shown as it is, withoutTry again.Other merge requests block this MR: a merge request that this one depends on is not merged yet (merge request dependencies, GitLab Premium and Ultimate).This project requires merge requests to go through the merge train. Set auto_merge to true to add this merge request to the train instead.: the project takes merge requests only through the merge train, so a direct merge is refused. In the API, merge withauto_mergeset totrue.The target branch is scheduled for deletion. Please wait for the branch to be retargeted.: the target branch is about to be deleted after another merge request was merged from it. Wait until GitLab moves this merge request to a new target branch, then merge again.Only fast-forward merge is allowed for your project. Please update your source branch: the project uses fast-forward merges and the source branch is behind the target branch, so rebase it first. If Enable automatic rebase prior to merge is selected in the merge request settings (the projects API has it from GitLab 19.4), GitLab rebases it for you, and a conflict then givesAutomatic rebase before merge failed because the source branch conflicts with the target branch. Rebase the source branch manually and resolve the conflicts.Merge request is not mergeable: when the merge started, the merge request was no longer mergeable. Reload the page to see which merge check stops it now.- On a merge train (GitLab Premium and Ultimate): when the project merges with fast-forward or semi-linear history and does not allow skipping the merge train, the train merges from its own ref. From GitLab 19.3 the message then goes on with
. Explanation:and the first merge check that failed, and the merge request's activity shows, for example,removed this merge request from the merge train because the merge could not be completed. Merge request is not mergeable. Explanation: The pipeline must succeed.The other explanations areThe merge request must not have conflicts.,The source branch must exist and contain commits.,The merge request must be open.,The merge request must not be a draft.,The merge request must be approved.,All requested changes must be resolved.,All merge requests that block this one must be merged.,All external status checks must pass.,The title must match the required pattern.,The title or description must reference a Jira issue.,The files must not be locked by another user.,The LFS files must not be locked by another user.,The current time is outside of the scheduled merge time.,The security policy pipeline must complete.andAll security policy violations must be resolved.They stay in English when GitLab is set to another language. With merge commits the message has no explanation, unless the feature flagmerge_trains_use_train_ref_for_standard_merges(from GitLab 19.2, off by default) is on. The same step also refuses withOutdated merge train: Squash commit SHA missing.when squashing was turned on after the merge request joined the train,Outdated merge train: Unexpected commit SHA in train ref parameters.when it was turned off, orOutdated merge train: Merge source out-of-date.when the train ref moved during the merge. Add the merge request to the train again (GitLab's from_train_ref.rb, refresh_merge_request_service.rb and the checks in mergeability/). Branch has been updated since the merge was requested. Please review the changes.: someone pushed to the source branch after you loaded the page you merged from (in the API: theshayou sent is not the head of the source branch). Look at the new commits, then merge again.This merge request has merge conflicts. Rebase the source branch or resolve the conflicts before merging: Git found conflicts while merging.Something went wrong during merge pre-receive hook.and the hook's own message: a check before the commit is accepted, such as a server hook or a push rule, refused the merge commit.An error occurred while merging: any other failure. The cause is only in the GitLab logs, which an administrator can read.
GitLab's merge_service.rb, from_source_branch.rb, ee/…/merge_base_service.rb and mr_widget_options.vue, read on November 3, 2026.
With push rules (GitLab Premium and Ultimate), GitLab checks the merge commit message and your commit email before the merge starts. A fast-forward merge makes no merge commit, so there only a squash commit message is checked. A mismatch shows in the same red box as one of Commit message does not follow the pattern '...', Commit message contains the forbidden pattern '...', Author's commit email '...' does not follow the pattern '...' or Commit message must contain a DCO signoff, with the rule's expression or your email in the quotes. When you squash, the squash commit message is checked too, for example Squash commit message does not follow the pattern '...'. Edit the merge commit message in the widget to match the rule, or add a Signed-off-by: line, then merge again (GitLab's merge_base_service.rb, merge_widget.vue and push rules).
The GraphQL mergeRequestAccept mutation checks four things first and returns the first that fails in errors: The merge request is already scheduled to be merged (auto-merge is already set), This branch cannot be merged (not mergeable now, or not eligible for the auto-merge strategy you asked for), Pre-merge hooks failed (the push rule check above) and The merge-head is not at the anticipated SHA (the sha you sent is not the head of the source branch). When these pass, the merge runs in the background and errors stays empty, so a later failure shows only in the mergeError field of the merge request (GitLab's accept.rb).
The /merge quick action needs the head SHA as well. Through the notes API, send it as merge_request_diff_head_sha. Without it, the summary of the answer says The `/merge` quick action requires the SHA of the head of the branch., and with an old one Branch has been updated since the merge was requested. Nothing is merged in either case (GitLab's merge_request_actions.rb and notes API).
Before a merge starts, the merge button can open Merge unverified changes? with The merge checks are incomplete because the latest pipeline failed, the pipeline status cannot be verified, or the merge request target branch was changed. You should run a new pipeline before merging. and Are you sure you want to attempt to merge? It comes when the latest pipeline failed or was canceled, or when GitLab moved the merge request to a new target branch. Run pipeline starts a new pipeline, and Merge unverified changes merges anyway. On a merge train the dialog is Start merge train instead (GitLab's merge_failed_pipeline_confirmation_dialog.vue and merge_widget.vue).
When the Resolve conflicts button is missing
The merge conflicts for this merge request cannot be resolved through GitLab. Please try to resolve them locally. The merge conflicts for this merge request have already been resolved. Please return to the merge request.
On the merge check Merge conflicts must be resolved., GitLab shows Resolve locally, which opens the steps to check out and merge the branches on your machine, and Resolve conflicts, which opens the conflicts page. Resolve conflicts is there only when GitLab can resolve every conflicting file in the browser, you may push to the source branch, and the source branch is not protected. A file counts when it is a text file, not binary, under 200 KB with the conflict markers added, in UTF-8, and at the same path in both branches. When the project uses fast-forward merges or Merge commit with semi-linear history and the source branch must be rebased first, neither button is shown.
The conflicts page shows the first line above when a file breaks one of those rules, and the second when the merge request no longer conflicts. For someone who may not push to the source branch, the page is a 404. To resolve on your machine, merge the target branch into the source branch (or rebase onto it), fix the files, and push (GitLab's conflicts.vue, merge_request_presenter.rb, conflicts_controller.rb and parser.rb, and the resolve conflicts documentation).
If Commit to source branch on the conflicts page fails, GitLab shows an alert and commits nothing. From GitLab 19.1 the alert gives the server's words when there are any: the message of a push rule or server hook that refused the commit, or The merge conflicts for this merge request have already been resolved. when someone resolved them first. Otherwise it says Failed to save merge conflict resolutions. Please try again., and up to GitLab 18.4 it said Failed to save merge conflicts resolutions. Please try again! whatever the cause (GitLab's store/index.js and conflicts_controller.rb, merge request !236793).
What to do
- 405: fix what
detailed_merge_statusnames, then merge again. - 409: look at the new commits, then merge with the new head.
- 422: read the merge request again: if it now says
conflictorneed_rebase, resolve or rebase first. - 401: ask a maintainer, or check who may merge into the target branch under Settings > Repository > Protected branches.
- 400: send
shawith the head commit you reviewed.
In IntelliJ IDEA: "Review has conversations that must be resolved" and "Source branch must be rebased before merging"
The GitLab merge requests built into IntelliJ IDEA show these two lines in a merge request's status. In the source (checked October 30, 2026):
- "Review has conversations that must be resolved" shows when the target project has All threads must be resolved turned on (GraphQL
onlyAllowMergeIfAllDiscussionsAreResolved) and at least one thread of the merge request that can be resolved is not resolved; a standard comment, which cannot be resolved until someone replies to it, does not count (GitLabMergeRequestStatusViewModel.kt, GitLabMergeRequestDiscussionUtil.kt). It is the case GitLab callsdiscussions_not_resolved. The setting is under Settings > Merge requests > Merge checks (GitLab: Prevent merge unless all threads are resolved). A report that the line showed all the time was marked fixed on May 29, 2024 (IJPL-81324). - "Source branch must be rebased before merging" shows, with a Rebase button, when the merge request is open, you can merge it, the target project merges by fast-forward (
mergeRequestsFfOnlyEnabled), and GitLab says the source branch has to be rebased (shouldBeRebased). It is the case GitLab callsneed_rebase: a fast-forward merge is only possible when the target branch has no commits that the source branch lacks (GitLab: Fast-forward merge). Rebase asks GitLab to rebase the source branch on the server (PUT /projects/:id/merge_requests/:merge_request_iid/rebase) and reloads the merge request while GitLab says the rebase is in progress; nothing happens in your local clone (GitLabMergeRequestDetailsStatusChecksComponentFactory.kt, GitLabMergeRequestFullDetails.kt, GitLabMergeRequest.kt). When GitLab does not rebase, see why the rebase did not happen.
In IntelliJ IDEA: "All required checks have passed", "Checks in progress…" and "Checks failed"
The GitLab merge requests built into IntelliJ IDEA also put one line for the pipeline in a merge request's status, with a Details… link to its jobs. In the source (checked October 30, 2026), the line reads the jobs of the merge request's head pipeline (up to 1,000), and a job counts as required unless it is allowed to fail (allowFailure):
- "All required checks have passed" when every required job succeeded, also when no job is required.
- Otherwise "Checks in progress, and some already failed…" when a job is still in progress and a job failed, "Checks in progress…" when a job is in progress and none failed, and "Checks failed" in every other case.
- Failed and canceled jobs count as failed; created, pending, preparing, running, scheduled and waiting-for-resource jobs count as in progress. Manual and skipped jobs are neither, so a required job that is manual or skipped, with nothing running or failed, makes the line read "Checks failed". A manual job is required when it has
allow_failure: false, the default forwhen: manualinsiderules(a blocking manual job: the pipeline stops at its stage until someone runs it); outsiderules, a manual job is allowed to fail by default (GitLab: allow_failure, Types of manual jobs; IntelliJ IDEA: GitLabMergeRequestStatusViewModel.kt, pipeline.graphql, CodeReviewDetailsStatusComponentFactory.kt). - Without a head pipeline, or with a pipeline without jobs, the line is not shown.
In IntelliJ IDEA: "Branch has conflicts that must be resolved"
The GitLab merge requests built into IntelliJ IDEA also show "Branch has conflicts that must be resolved" in a merge request's status, with a Resolve link. In the source (checked October 30, 2026), the line follows the merge status GraphQL gives (mergeStatusEnum): CANNOT_BE_MERGED ("There are conflicts between the source and target branches") shows it; CHECKING, UNCHECKED and CANNOT_BE_MERGED_RECHECK ("Currently unchecked. The previous state was CANNOT_BE_MERGED"), and the time before the details have loaded, show "Checking branch for conflicts" instead; CAN_BE_MERGED hides it (GitLab: MergeStatus; IntelliJ IDEA: GitLabResolveConflictsLocallyViewModel.kt, GitLabMergeRequestFullDetails.kt, GitLabMergeRequestDetailsStatusChecksComponentFactory.kt, CodeReviewDetailsStatusComponentFactory.kt). Resolve asks whether to rebase or merge, fetches the target branch, checks out the source branch (adding a remote for the source project when it is a fork your clone does not have yet), and then, in your local clone, rebases the source branch onto the target branch or merges the target branch into it. Any conflicts are then resolved in the IDE, and the merge request changes only when you push; after a rebase, that push has to be a force push (ResolveConflictsLocallyViewModel.kt). Resolve is greyed out, with the reason on it, while the repository is in the middle of a merge or a rebase ("Merge is already in progress"), when GitLab gives no source project ("The source project is private or does not exist"), and when the current branch already tracks the source branch and has the commit GitLab gives as the base of the diff (diffRefs baseSha, "Merge base of the branch the comment was made on") in its history ("Already resolved locally, push your changes to resolve") (CollaborationToolsBundle.properties, GitLabBundle.properties, GitLabResolveConflictsLocallyViewModel.kt).
GitLab merge requests in IntelliJ IDEA
Merge Request (MR) Review Inbox for GitLab, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, shows a merge request's merge checks before you merge: approvals, requested changes, unresolved threads, the pipeline, conflicts, and GitLab's other reasons from detailed_merge_status, with the ones that block the merge first. It merges the head commit you had on screen. When GitLab refuses, it says which case it is: for 405, that GitLab cannot merge it now and to see the merge checks; for 409, that the source branch changed and to refresh; for 422, that GitLab could not merge it, with GitLab's words; for 401, that your role or the project's settings may not allow it. When a rebase is needed, it offers one. Reading is free; approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).
Get it on JetBrains Marketplace
GITLAB is a trademark of GitLab Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by GitLab Inc. or JetBrains.
More: GitLab auto-merge refused (405) or canceled · GitLab 404 "Project Not Found" · GitLab "insufficient_scope" · GitLab 401 "invalid_token" · GitLab approval refused (401, 409) · GitLab comment or thread refused (400, 403) · GitLab merge request not created (409, 422, 400) · GitLab rebase refused or failed (403, 409) · GitLab merge request list refused (400, 404) · GitLab merge request changes cut short ("1000+", too_large) · GitLab 429 "Retry later" (rate limits) · GitLab merge refused or failed over squashing · GitLab "compare_timeout": true (diff limits) · GitLab merge request plugins for IntelliJ IDEA, compared · 日本語