Lesstep
GitLab · merge requests · squash and merge · Checked October 28, 2026

GitLab: a merge refused or failed over squashing

GitLab squashes the commits of a merge request into one when the squash setting asks for it. When the setting requires squashing and the merge does not ask for it, or the squash itself fails, the merge does not happen. The merge API then answers only 422 Branch cannot be merged, and GitLab keeps the reason in the merge_error of the merge request, which is also the message shown in the merge request (GitLab source lib/api/merge_requests.rb and app/services/merge_requests/merge_service.rb, read October 28, 2026). The reasons:

This project requires squashing commits when merge requests are accepted.
Squashing failed: The commits have conflicting changes. Squash the commits locally, resolve the conflicts, then push the branch.
Squashing failed: Squash the commits locally, resolve any conflicts, then push the branch.

The squash options

Why the merge did not happen

How to see the setting that applies

curl -H "PRIVATE-TOKEN: your-token" "https://gitlab.com/api/v4/projects/group%2Fproject/merge_requests/42"

query {
  project(fullPath: "group/project") {
    mergeRequest(iid: "42") { squash squashOnMerge squashReadOnly mergeError }
    branchRules { nodes { name squashOption { option } } }
  }
}

What to do

For the other answers of the merge API (405, 409, 401, 400), see why GitLab refused the merge.

GitLab merge requests in IntelliJ IDEA

Merge Request Inbox for GitLab, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, merges a merge request from the IDE. Its merge dialog reads how GitLab will squash the merge request (squashOnMerge, squashReadOnly), so the squash setting of a protected target branch counts too: when squashing is required it selects the squash checkbox and locks it, when it is not allowed it clears and locks it. When a merge fails with 422, it shows the reason GitLab kept (merge_error), such as "This project requires squashing commits when merge requests are accepted." Before version 1.0.19, it went by the project setting only. Reading is free; approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).

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 merge refused (405, 409, 422) · GitLab auto-merge refused (405) or canceled · GitLab rebase refused or failed (403, 409) · GitLab 429 "Retry later" (rate limits) · GitLab "compare_timeout": true (diff limits) · GitLab merge request plugins for IntelliJ IDEA, compared · 日本語