How to abort a merge | The Git Reset Command | The Git Merge Command
While working with Git you will merge branches into the branch you are currently working on. When doing so, merge conflicts can occur. It might happen that you start a merge, merge conflicts occur and that you want to abort the merge, e.g. because there are a lot of conflicts but you don’t have the time to fix them right now or because you don’t know how to solve the conflicts correctly. Luckily, aborting a merge is possible in Git.
Before starting a merge, you should commit or stash your latest changes because it is possible that Git won’t be able to restore your pre-merge state completely in case that you want to abort a merge. When you started merging and merge conflicts occur, you can abort the merge (i.e. reset only changes caused by the merge) by using the Git reset command with the –-merge option:
git reset --merge ORIG_HEAD
You could also use the Git merge command with the –-abort option:
git merge --abort
Both commands will "abort the current conflict resolution process, and try to reconstruct the pre-merge state".
I created a GitHub repository where you can try out the mentioned commands in a safe environment.