A merge commit looks empty in `git show`, but a bug slipped in through it. How do you inspect it?
AdvancedScenarioBranching and Merging Workflows
Answer
Situation read → Default git show on a merge prints a combined diff showing only conflict-resolution changes. If resolution was wrong ("evil merge"), the change lives there.
What I'd do →
git show --cc <merge-sha>shows only hunks that differ from all parents.- Compare against each parent:
git diff <merge-sha>^1 <merge-sha>andgit diff <merge-sha>^2 <merge-sha>. git show -m --first-parent <merge-sha>shows the diff against the first parent only.- Rebuild the merge to compare:
git checkout <merge-sha>^1 && git merge <merge-sha>^2.
Why → Conflict resolutions are not attributed to either side, so you have to compare against each parent to see what the merger did.
Interview tip → This is why many teams prefer squash merges for features: the PR diff is the whole change.
More on Branching and Merging Workflows
You run `git pull` and Git stops with a merge conflict in `app.py`. What do you do?BeginnerYour feature branch is three weeks old and `main` has moved a lot. Merge `main` in, or rebase onto it?IntermediateThe team argues about fast-forward merges versus merge commits on `main`. How do you settle it?BeginnerA teammate branched from the wrong base, and their PR shows 40 unrelated commits. How do you fix it?IntermediateBefore merging, you want to see exactly what the feature branch adds compared to `main`. Which commands?BeginnerHalfway through a merge you realise you pulled the wrong branch. How do you back out?Beginner