Reputation: 13297
I have a couple of bad merges in history (due to human error). I want a quick way to find out if I have more like these. In order to automate it, I want to see, for every merge commit, the difference between as if the merge would be performed automatically (with a given conflict resolution strategy) and what actually happened in a given merge.
How can I do it?
Upvotes: 0
Views: 69
Reputation: 488103
You must make that automatic merge.
To do so, check out one of the two parents of the suspect merge, giving yourself a "detached HEAD" in the process. If $suspect_merge
contains a suitable name for the suspect merge (e.g., a hash ID):
git checkout $suspect_merge^1
Then, run git merge
on the other of the two parents:
git merge [options] $suspect_merge^2
The merge will either finish and make a new commit on your detached HEAD, or fail due to conflicts. If it fails, you can finish it manually and correctly, and then commit.
Now you have a good merge that you can compare to the suspect merge:
git diff $suspect_merge HEAD
When you git checkout
any named branch, the merge you just made on the detached HEAD is abandoned. It will eventually (typically some time after 30 days, when its reflog entry expires) be garbage collected. To keep it around, give it a name: a branch or tag name works well.
Upvotes: 1