What git diff --cached is built on.
git diff-index compares the index (or working tree) against an arbitrary tree-ish, usually a commit. It's what powers 'git diff --cached' and 'git diff HEAD'. If you need 'has anything changed since this commit?', this is the tool.
Pick a tree on the left (any commit/tag/tree SHA), and either the index or the working tree on the right. Same output language as diff-files; just a different left-hand side.
git diff-index [--cached] [--merge-base] [-p] [--raw] [--name-only] [-q]
<tree-ish> [<path>...]| Flag | What it does |
|---|---|
<tree-ish> | The committed/tagged/tree SHA on the left side. Required. |
--cached | Compare the index (not the working tree) to <tree-ish>. This is 'git diff --cached'. |
--merge-base | Use the merge-base of HEAD and <tree-ish> as the left side instead. |
-p | Produce a unified patch. |
--raw | Machine-readable mode/SHA/status output (default-ish). |
--name-only | Only print changed paths, one per line. Great for piping. |
-q / --quiet | Silent; exit non-zero if any difference exists. |
git diff-index -p HEADgit diff-index --cached -p HEADgit diff-index --name-only v1.0git diff-index --quiet HEAD || exit 1Hit each option, then Check answers. Score is recorded; Next is always open.