๐ŸŽ“ A1Learner
๐Ÿ”
0 of 50 lessons completed

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-check2

Stop the merge

Abort prints nothing. Status shows a clean tree.

$ git merge --abort
$ git status

The file is back as it was

The four-litre line is back. The markers are gone.

$ cat notes.txt

Example

$ git merge price-check2
$ git merge --abort
$ git status

Key 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?