GitLab: why the rebase did not happen
Rebasing a merge request through the API (PUT /projects/:id/merge_requests/:merge_request_iid/rebase) is refused at once with 403 or 409, or answers 202, which only means that GitLab has queued the rebase: it runs afterwards and can still fail. All of this is from GitLab's source (the rebase endpoint in lib/api/merge_requests.rb, MergeRequests::RebaseService, and rebase_async in app/models/merge_request.rb), read on October 24, 2026.
The answers
- 403
{"message":"403 Forbidden - Cannot push to source branch"}: your account may not push to the source branch, in the project the branch is in (for a merge request from a fork, the fork). A rebase rewrites that branch, so GitLab asks for the same right as a push. - 403
403 Forbidden - Source branch is protected from force push: the source branch is protected, and its protection does not allow force push. A rebase replaces the branch's commits, which is a force push. - 403
403 Forbidden - Source branch does not exist: the source branch has been deleted. GitLab's API documentation gives "You don't have permission to push" as the reason for this one too, but the source checks only whether the branch exists. - 409
{"message":"409 Conflict: Resource lock"}: the merge request is not open (closed, merged or locked), or a rebase of it is already queued or running. This answer is not in the API documentation. - 409
Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.: GitLab could not lock the merge request within about 5 seconds.
After the 202 ({"rebase_in_progress":true}), a rebase that fails leaves its reason in the merge request's merge_error:
Rebase failed: Rebase locally, resolve all conflicts, then push the branch.: the source branch's commits do not apply cleanly onto the target branch. GitLab also gives this text for failures it does not explain.The rebase pre-receive hook failed: ….: the checks a push goes through before it is accepted (pre-receive) refused the rebased commits; the rest of the text is theirs.Rebase failed: ….with Git's own message: Git itself stopped.Source branch does not exist: the branch was deleted after the rebase was queued.
GitLab also writes a failed merge there. merge_error stays until the next push to the source branch, or until the merge request is closed or merged.
On the merge request page, GitLab drops the final period of merge_error and adds . Try again., whatever the cause (GitLab's mr_widget_options.vue), so the page reads Rebase failed: Rebase locally, resolve all conflicts, then push the branch. Try again. It does not mean that the same rebase will work a second time. With conflicts, rebase locally as below.
A token without the api scope is refused with 403 too, but that answer says insufficient_scope; see which scope to add. A project path that does not exist, or that you cannot see, answers 404; see address or permission.
To rebase from the IDE: Merge Request (MR) Review Inbox for GitLab, a plugin for JetBrains IDEs, offers to rebase the source branch when GitLab says the merge request needs it, and from version 1.0.14 shows what GitLab put in merge_error when the rebase fails afterwards.
Where it stands
curl -H "PRIVATE-TOKEN: your-token" "https://gitlab.com/api/v4/projects/group%2Fproject/merge_requests/42?include_rebase_in_progress=true"
While rebase_in_progress is true, the rebase is still queued or running. Once it is false, merge_error is null if the rebase worked, or says why it failed. state tells whether the merge request is still open. Use your own server's address instead of gitlab.com.
The /rebase quick action
A comment with /rebase asks for the same rebase. GitLab offers the command only when the merge request is open, its source branch exists and you may push to that branch. It then checks these in order and answers with one of them:
This merge request branch is protected from force push.: the same check as the 403 "Source branch is protected from force push" above.This merge request is currently in an unmergeable state, and cannot be rebased.: GitLab has already marked the merge request as one that cannot be merged, for example because of conflicts. Rebase locally, resolve the conflicts and push.A rebase is already in progress.: an earlier rebase has not finished. Wait untilrebase_in_progressisfalse.Scheduled a rebase of branch feature.: the rebase is queued, as after the 202 above. If it fails, the reason is inmerge_error.
If the same comment also holds /merge, GitLab drops the merge so that it does not race the rebase. Through the notes API, a note that holds only /rebase is answered with 202, and the sentence is in summary (GitLab's merge_request_actions.rb, update_service.rb and notes_helpers.rb, read on November 3, 2026).
The Rebase button
The Rebase button on the merge request page runs the same checks as the API, in this order, before it queues anything. When one fails, GitLab shows an alert at the top of the page:
Failed to rebase: Source branch does not exist. Failed to rebase: Cannot push to source branch. Failed to rebase: Source branch is protected from force push. Failed to rebase: Failed to enqueue the rebase operation, possibly due to a long-lived transaction. Try again later.
They mean the same as the 403 and 409 answers above. Failed to rebase. Please try again. comes when the answer carries no reason, such as a server error. When the rebase has run and worked, a short Rebase completed message shows; when it failed, the red box shows merge_error as described above. Something went wrong. Please try again. means the page could not read the merge request's state while it waited (GitLab's merge_requests_controller.rb, rebase_service.rb, rebase.vue and utils.js, read on November 3, 2026).
The page has a second Rebase button, and the first one can come with a choice. Under the merge details, The source branch is 3 commits behind the target branch. has a Rebase source branch link for anyone who may push to the source branch. It first asks Rebase source branch? with This will rebase all commits from the source branch onto the target branch. and after Rebase it shows Scheduled a rebase of branch feature. When the project rebases automatically before merge and has no merge trains, the link reads Rebase with pipeline, and the line below says Source branch will be rebased without pipeline. In the merge checks, Rebase without pipeline sits next to Rebase when you may push to the source branch and the project does not require a successful pipeline, or also counts a skipped pipeline as successful. It is the API's skip_ci=true, so no pipeline runs for the rebased branch. On a merge request from a fork, when you can run pipelines in the parent project and the latest pipeline did not run there, Rebase first asks Are you sure you want to rebase? The new pipeline would run the fork's code, and the warning says CI variables could be exposed (GitLab's merge_widget.vue, rebase_confirmation_dialog.vue, checks/rebase.vue and merge_request_poll_widget_entity.rb).
What to do
- 403 "Cannot push to source branch": ask a maintainer for the Developer role, or, if the branch is protected, for your role to be allowed to push to it. For a merge request from a fork, ask its author to rebase, or to select Allow commits from members who can merge to the target branch; GitLab's documentation says this is for forks that are publicly accessible, and that you then need the Developer role or higher in the project you merge into.
- The Allow commits box cannot be selected: GitLab gives the reason under it.
Not available for private projects: the fork or the project you merge into is private.Not available for protected branches: the source branch is protected in the fork.Merge request author cannot push to target project: despite the words, GitLab checks that the author may push to the fork. With no reason shown, look at the project you merge into, where Merge requests and Repository must be open to everyone with access. The box is under Contribution when you create or edit a merge request from a fork, and only people who may push to the fork see it (GitLab's merge_request.rb, merge_requests_helper.rb and _contribution.html.haml). - 403 "protected from force push": a maintainer can allow force push in the branch's protection. Without it, bring in the target branch with a merge instead (
git fetch origin,git merge origin/main, then an ordinarygit push): in the source, GitLab asks for a rebase only while the target branch's latest commit is not in the source branch, and a merge puts it there. - 403 "Source branch does not exist": push the branch again (
git push -u origin feature), or close the merge request. - 409 "Resource lock": look at
state. If the merge request is open, a rebase is already under way: wait, and read the merge request again as above. - 409 "Failed to enqueue": try again in a moment.
- "Rebase failed: Rebase locally, resolve all conflicts…": do as it says:
git fetch origin,git rebase origin/main, resolve the conflicts, thengit push --force-with-lease. - "The rebase pre-receive hook failed": fix what the rest of the text names, then rebase again.
GitLab merge requests in IntelliJ IDEA
Merge Request (MR) Review Inbox for GitLab, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, offers to rebase the source branch when GitLab says the merge request needs a rebase. When GitLab answers 403, it says that your role in the project or its settings may not let your account do it, with GitLab's words; other refusals in GitLab's words. After the 202, it says that GitLab is rebasing the branch and to refresh in a moment; from version 1.0.14, when the rebase fails afterwards, the overview shows what GitLab put in merge_error, until the branch is pushed again or the merge request can be merged. Reading is free; rebasing, 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 merge refused (405, 409, 422) · GitLab auto-merge refused (405) or canceled · GitLab approval refused (401, 409) · GitLab comment or thread refused (400, 403) · GitLab merge request not created (409, 422, 400) · GitLab "insufficient_scope" · GitLab 401 "invalid_token" · GitLab 404 "Project Not Found" · 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 · 日本語