Abort a Git merge after conflicts

Stop an unfinished merge, understand the limits of restoring earlier local changes, and choose a separate recovery path for an already committed merge.

Best practices
Illustration of Git branches and version history

Run git merge --abort to stop an unfinished merge. Git attempts to reconstruct the state before the merge began. If you started with uncommitted changes, especially if you edited them further during the merge, reconstruction is not always possible.

git merge feature-x
# If the merge stops and you decide not to continue:
git merge --abort
git status

A clean checkout before merging makes recovery more predictable. Commit or stash work you intend to keep, and preserve any useful conflict-resolution edits separately before aborting. A successful abort does not imply the checkout is clean if it was dirty beforehand.

Distinguish the operation in progress

git status tells you whether Git is merging, rebasing, cherry-picking, or reverting. Use the matching command:

git rebase --abort
git cherry-pick --abort
git revert --abort

These are alternatives for different operations, not a sequence to run together. With merge autostash, merge --abort applies the temporary stash; that application can itself need attention. git reset --merge has a different treatment of MERGE_AUTOSTASH, so it is not an unconditional substitute.

Try a different integration approach

Aborting leaves the underlying divergence unresolved. On another attempt, you can use git mergetool to resolve conflicts or break a large change into smaller integrations.

git merge -X theirs feature-x

The theirs strategy option favors the incoming side for conflicting hunks where the strategy can apply it. It does not replace the complete result with that branch, and it does not guarantee every conflict disappears. It is also different from the ours merge strategy, which records a merge while retaining the current tree.

Rebasing a private feature branch onto an updated main can change how conflicts are presented, but it does not guarantee fewer conflicts and rewrites the feature history. Do that deliberately on the feature branch, not as a mechanical fallback.

What if the merge already finished?

There is no in-progress merge to abort after a commit or completed fast-forward. Inspect the log and reflog. ORIG_HEAD often identifies the previous tip immediately after a merge, but later commands can overwrite it.

For an unshared merge, a verified reset target may be appropriate; git reset --hard TARGET discards local tracked changes. For a shared merge commit, git revert -m 1 MERGE_COMMIT usually preserves collaboration history, but choose the correct parent and understand its effect on future merges. A fast-forward has no merge commit to revert with -m.

Short-lived branches, smaller refactors, and coordinated formatting changes help keep future conflicts manageable.

See git-merge.

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting