What git show uses internally.
Diffs two tree-ish objects (or one tree against its parent) and is what git show and git log -p use under the hood. If you're scripting commit -> tree -> diff, this is the workhorse you actually call.
Trees in, diff records out. With one tree it walks a commit's parents; with two it compares them directly; with -r it recurses into subdirectories instead of summarizing them as a single tree change.
git diff-tree [--stdin] [-m] [-s] [-v] [--pretty] [-t] [-r] [--root]
[<common-diff-options>] <tree-ish> [<tree-ish>] [<path>...]| Flag | What it does |
|---|---|
<tree1> [<tree2>] | One tree-ish diffs commit-vs-parent; two tree-ishes diffs them directly. |
-r / --recursive | Recurse into subtrees; without it, directory changes collapse to a single entry. |
--root | For root commits, show the full tree as an addition instead of producing nothing. |
-c | For merges, show a combined diff against all parents (only paths changed vs every parent). |
--cc | Like -c but further compresses uninteresting hunks; what git show uses for merges. |
--combined-all-paths | With -c/--cc, list the path under every parent (useful for renames across a merge). |
-m | For merges, emit a separate diff against each parent instead of a combined one. |
--name-only / --raw | Trim output to paths only, or emit the machine-readable raw record format. |
rev-list output and want patches or raw records per commit.git diff-pairs with explicit (oid1, oid2) records via -z --raw.git show does, for tooling parity.git diff-tree -p -r HEADgit diff-tree -r -z --raw HEAD^ HEADgit show doesgit diff-tree --cc -r <merge-sha>git diff-tree --no-commit-id --name-only -r HEAD-r; without it directory-level changes collapse and you'll wonder where your files went.--root so the very first commit isn't silently empty.git show's behavior for merges with --cc; use -m only when you genuinely want per-parent diffs.-r, a change inside src/foo/bar.c shows up only as src changing - confusing if you weren't expecting tree-level output.--no-commit-id when piping raw records or it'll corrupt parsers.-c/--cc/-m, diff-tree shows nothing for the merge commit - that's intentional, not a bug.Hit each option, then Check answers. Score is recorded; Next is always open.