THE GITHTML FIELD GUIDE
See staged and unstaged changes with git diff
Use git diff for unstaged tracked changes and git diff --staged for the proposed commit. The first compares working files with the index; the second compares the index with HEAD. If you stage everything, plain git diff can be empty even though a commit is ready. Neither view automatically displays untracked file contents.
Match the comparison to your question
There is no single universal diff because Git has several meaningful snapshots. Ask whether you want to inspect edits since staging, what a normal commit would record, or the total tracked change since the current commit. Those questions map to different comparisons. An empty result is useful only after you know which pair of states was compared.
A common example is a configuration file staged with a new endpoint, then edited again to change a timeout. The staged diff shows the endpoint. The ordinary diff shows the timeout. Reviewing just the file in your editor shows both and can hide the fact that only one change is prepared for the commit.
Run focused comparisons
Start with a summary if the patch is large, then inspect actual lines. Use -- to separate a path from revision arguments. The example narrows the review to a real configuration filename; replace it with the path you are investigating. These commands leave both the index and working files unchanged.
- Check git status for untracked files, because an empty tracked-file diff does not prove that the directory contains no new work.
- Review the full staged patch before committing, not only the stat summary. File counts and line totals cannot reveal secrets or an incorrect value.
git diff --stat
git diff -- config.json
git diff --staged -- config.json
git diff HEAD -- config.jsonRecognize the limits of a clean-looking patch
Whitespace settings, filters, binary files, and rename detection can affect presentation. If an expected change seems absent, first confirm the file path and repository, then inspect status and the staging state. Do not immediately assume that Git ignored a saved edit or that history needs to be reset. The explanation is often that you selected the wrong comparison.
After committing, the staged diff normally becomes empty because HEAD now includes that snapshot. Any later or deliberately excluded working edits can remain visible in the ordinary diff. This is a good outcome when you are separating independent fixes. For a final review, combine the patch with relevant tests: a syntactically tidy diff can still change behavior incorrectly. Diff explains what changed between snapshots, not whether the resulting program is correct.
If the pager opens, use its normal navigation and exit controls. Leaving the pager does not cancel an operation or modify the patch being displayed.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.