I was running a simple merge and expecting no conflicts, and I ran git merge my_dev_branch
However I got a merge conflict which looked messy to resolve, and made me think that I wasn't clear on my branch history. Rather than resolve the conflict I would like to abandon the merge and go back to where I was before.
Two questions:
git checkout HEAD <filename>
on each file per this question and that this would amount to abandoning the merge?You can undo a Git merge using the git reset –merge command. This command changes all files that are different between your current repository and a particular commit. There is no “git undo merge” command but the git reset command works well to undo a merge.
You can use the git reset --merge command. You can also use the git merge --abort command.
Use git-reset or git merge --abort to cancel a merge that had conflicts. Please note that all the changes will be reset, and this operation cannot be reverted, so make sure to commit or git-stash all your changes before you start a merge.
git merge --abort is equivalent to git reset --merge when MERGE_HEAD is present. After a failed merge, when there is no MERGE_HEAD , the failed merge can be undone with git reset --merge , but not necessarily with git merge --abort .
Try git merge --abort
. Handy, eh?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With