Progress:
TIER 3 · MODULE 23· Expert

git diff-files

What git diff (no args) is built on.

🎯 What & why

git diff-files compares the working tree against the index (staged content). It's the engine under bare 'git diff' (no args) and is the canonical way for scripts to ask 'what's modified but not yet staged?'

🧠 Mental model

Two sides: index (left) and working tree (right). For unmerged paths it sees stages 1/2/3 (base/ours/theirs) and can show the relevant view of conflicts.

🛠️ Synopsis

git diff-files [-p] [-u] [-q] [--raw] [-1|-2|-3|-c|--cc]
               [--base|--ours|--theirs] [--ita-invisible-in-index] [<path>...]

🎚️ Switches & options

FlagWhat it does
-p / -uGenerate a unified patch (text diff). Same as 'git diff' output.
-qSilent; exit non-zero if any difference exists. Great for scripts.
--rawDefault-ish machine-readable format: mode/sha/status per path.
-1 / -2 / -3 (--base/--ours/--theirs)For unmerged paths, diff against that conflict stage only.
-c / --ccCombined / dense-combined diff for merge conflicts (multi-parent view).
--ita-invisible-in-indexTreat 'intent-to-add' (git add -N) entries as not-yet-in-index.

💡 Use cases

🧪 Examples

Show unstaged patch
git diff-files -p
Quiet check in a script
git diff-files --quiet || echo 'dirty tree'
Raw machine format
git diff-files --raw
Look at 'theirs' for conflicts
git diff-files --theirs path/to/conflicted

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.