this pull request cannot be automatically merged: rebase conflict
Fixes 'this pull request cannot be automatically merged' rebase conflicts by rebasing onto the updated base. Use when the PR page reports a rebase conflict. Not for merge commits the team forbids.
TL;DR
The base branch moved and your branch no longer rebases cleanly. Fetch, rebase onto the new base, resolve the conflicts, and force-push the branch.
Error
This branch has conflicts that must be resolved - This pull request cannot be automatically merged.Steps
- Fetch the latest base:
git fetch originthengit rebase origin/main(use your base branch name). Expected: git stops at the conflicting commits. - Resolve each conflict: edit the files,
git addthem,git rebase --continue. Expected: the rebase completes. - Force-push the rebased branch:
git push --force-with-lease. Expected: the PR updates and the conflict warning clears. - Confirm checks re-run on the new head SHA. Expected: the PR is mergeable again.
When to use
- The PR page says it cannot be automatically merged due to conflicts.
- The repo uses rebase merging or requires a linear history.
When not to use
- The team allows merge commits - then 'Update branch' with a merge commit is simpler.
- The conflict is on files you do not own; coordinate with the other author first.
Tool compatibility
- GitHub / GitLab / any git host.
- Git 2.x.
Variant phrasings
Conflicts only in generated files
Regenerate the files on top of the new base instead of hand-resolving.
Rebase conflicts on every PR
Rebase more often, or ask the team to enable merge-queue which handles it automatically.
Why it happens
The base branch advanced with changes touching the same lines as your branch. Git cannot decide which version wins, so automatic merging is blocked until a human resolves the overlap.
Edge cases
--force-with-leaseis safer than--force: it aborts if someone else pushed meanwhile.- Rebasing rewrites commit SHAs - warn collaborators on a shared branch before force-pushing.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_LonD68538YtIv5kD-6vgTA