Aborting a Merge
git merge --abort returns to the state before the merge.
Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
git switch -q -c feat
echo feat > a.txt && git commit -qam 'feat'
git switch -q main
echo main > a.txt && git commit -qam 'main'
git merge feat >/dev/null 2>&1
git merge --abort
git status -s | wc -l
cat a.txtResult
0 main
Exercise
Cancel.
git merge Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.