I\'ve merged two branches. Got lot\'s of conflicts. Resolved them all. Now I\'m not sure, maybe I\'ve made an error during conflict resolution. And I don\'t see no another way t
Yes, it is trivial. First of all, you need find sha1 id of the merge commit using git log
. When you do the next:
git checkout <sha1>^1
git merge <sha1>^2
you will be in a headless state. ^n
means n-th parent of a commit. So, no branches are created. You could resolve conflicts again more carefully and then
git diff HEAD..<sha1>
to see if there are any differences in the conflict resolutions.
BTW, branch in a git just a human-friendly name for a sha1 of a commit, so don't afraid to create them as much as you wish.
PS: If you work in Windows, ^
symbol in command line is special, you need to double it or quote command line arguments.
If you want to look at what the merge did you can do
git show <hash-of-merge-commit>
If you want to redo the entire merge you do
git checkout <branch-that-you-merged-to>
git reset --hard <hash-of-the-commit-just-before-the-merge>
git merge <branch-that-you-merged-in>
If you want to redo the merge and then compare the second merge to the first merge (to consider if it was better) you can do:
git checkout <branch-that-you-merged-to>
git rev-parse HEAD
This gives you the hash of the current commit. Note it down. Then do
git reset --hard <hash-of-the-commit-just-before-the-merge>
git merge <branch-that-you-merged-in>
Finish the merge, then do this to compare the merges
git difftool <hash-of-commit-noted-above>
If you felt that the original merge was better, you can do
git reset --hard <hash-of-commit-noted-above>