July July - 9 months ago 39
Git Question

Git: How to discard the merging conflicts with a commit

Now I'm in a merging state. I want to discard all changes, to back to the state that before the merging, and when I do the merge again, it says "Already up-to-date". Is there a nice way to do it?

My attempt:

git reset --hard head

but when I do the merge again, still conflict.
what I have to do is manually revert all changes by hand and do a empty commit, very tedious.


From what I understood you want to do a merge but, for every conflict, fallback to the version in the original branch instead of the one you are merging with.

If that's the case, tou can try using -Xours

git merge -Xours <name of your other branch>

There's also the option of falling back to the other branch's conflicted changes with -Xtheirs

For more reference, check git's advanced merging docs