How to undo a Git merge before that you haven't pushed remotely yet

If you have merge conflicts when you run git merge and just want to stop the merge, just run this command in your terminal: git merge --abort

This will abort the merge and undo any changes the merge would have introduced, effectively bringing you back to your branch’s previous state. You will still be able to try the merge again if you want by running git merge again.