Abort a Merge
Abort stops a merge and puts everything back. Use it when the conflict is bigger than you expected.
Start a merge that conflicts
The same line changed twice again, so Git stops.
$ git merge price-check2Stop the merge
Abort prints nothing. Status shows a clean tree.
$ git merge --abort
$ git statusThe file is back as it was
The four-litre line is back. The markers are gone.
$ cat notes.txtExample
$ git merge price-check2
$ git merge --abort
$ git statusKey points
- Abort only works while a merge is in progress.
- It returns the files to the state before the merge.
- It removes the conflict markers.
- No snapshot is made.
- You can try the merge again later.
- Aborting never deletes saved work.
Here, the merge starts, conflicts, and stops. Status shows a clean tree, as if the merge never happened.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What does git merge --abort do?