Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git get conflicts from past merge without running merge once again

Tags:

git

merge

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 to check is it true — just run merge again, and check conflicts one by one.

This means I need to create one more branch to store results of my merge, right?

Can I avoid it? Maybe it's possible to get all conflicting files with all these <<<<<<, ======, >>>>>> from somewhere in git, without running merge once again?

like image 573
shytikov Avatar asked Jun 15 '12 09:06

shytikov


1 Answers

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>
like image 197
Klas Mellbourn Avatar answered Oct 05 '22 11:10

Klas Mellbourn