After doing a \"simple\" merge (one without conflicts), git show
usually only shows something like
commit 0e1329e551a5700614a2a34d8101e92fd9f2ca
Seems like answered here: https://public-inbox.org/git/7vd392ezhx.fsf@alter.siamese.dyndns.org/
So in a similar way, running
$ git diff --cc $M $M^1 $M^2 $(git merge-base $M^1 $M^2)
should show a combined patch that explains the state at $M relative to the states recorded in its parents and the merge base.
I built a general-purpose approach to doing various operations on a merge's commits.
Step One: Add an alias to git by editing ~/.gitconfig
:
[alias]
range = "!. ~/.githelpers && run_on_merge_range"
Step Two: In ~/.githelpers
, define a bash function:
run_on_merge_range() {
cmd=$1; shift
commit=$1; shift
range=$(git show $commit | grep Merge: | awk '{print $2 "..." $3}')
echo "git $cmd $range $@"
if [ -z $range ]; then
echo "No merge detected"
exit 1
fi
git $cmd $range $@
}
Step Three: Profit!
git range log <merge SHA> --oneline
git range diff <merge SHA> --reverse -p
git range diff <merge SHA> --name-only
There is probably a LOT of room for improvement here, I just whipped this together to get past an annoying situation. Feel free to mock my bash syntax and/or logic.
in your case you just need to
git diff HEAD^ HEAD^2
or just hash for you commit:
git diff 0e1329e55^ 0e1329e55^2
You can create branch with HEAD set to one commit before merge. Then, you can do:
git merge --squash testing
This will merge, but not commit. Then:
git diff
If your merge commit is commit 0e1329e5, as above, you can get the diff that was contained in this merge by:
git diff 0e1329e5^..0e1329e5
I hope this helps!
If you are sitting at the merge commit then this shows the diffs:
git diff HEAD~1..HEAD
If you're not at the merge commit then just replace HEAD with the merge commit. This method seems like the simplest and most intuitive.