Interview Prep/Git & GitHub/Branching and Merging Workflows

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 →

  1. git show --cc <merge-sha> shows only hunks that differ from all parents.
  2. Compare against each parent: git diff <merge-sha>^1 <merge-sha> and git diff <merge-sha>^2 <merge-sha>.
  3. git show -m --first-parent <merge-sha> shows the diff against the first parent only.
  4. 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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Branching and Merging Workflows