Reviewing the index
Show staged changes
git diff --staged
Diffs index against HEAD. --cached is an exact synonym. See git-diff.
List staged file names
git diff --staged --name-only
Output
f.txt
Prints only the paths. Swap --name-only for --stat to get per-file counts. See git-diff.
Include unstaged edits
git diff HEAD
Compares everything to HEAD. Staged and unstaged changes appear in one patch. See git-diff.
Show unstaged only
git diff
Diffs the working tree. It compares your files with the index; these are changes you could still stage. See git-diff.
Related links
- git-diff manual (git-scm.com)
- Git cheatsheet (devhints.io)
0 Comments for this cheatsheet. Write yours!