Lessons · Git · the free way out of a merge or rebase
The free way out
While a merge or a rebase is stopped, git is holding the state you started from. --abort puts it back exactly.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
A conflict you do not understand is a conflict you should not resolve. Aborting costs nothing and a wrong resolution costs a change nobody will ever flag.
How to think about it
Abort, look at both branches with the pressure off, and start again knowing what you are choosing between.
Worked example
git merge featureStopped, with conflicts.
git status --shortUU f.txt.
git merge --abortAnd back.
git status --shortSilence: the tree is exactly as it was.
cat f.txtours -- your branch's version, untouched.
git log --onelineTwo commits. No half-finished merge in the history.
Your turn
Get out of the stopped merge and back to where you started.
git merge
Try it in a real repository
The trap
Using reset --hard to escape a stopped merge. It usually works and it also throws away anything else uncommitted; --abort is the one that knows what it is undoing.