git diff Show the exact lines that changed

Prints the differences between versions: your working folder against the staging area by default, or between commits and branches. Lines starting with + were added and - were removed.

Synopsis

git diff [OPTION]... [COMMIT] [-- PATH]
git diff [OPTION]... COMMIT COMMIT

Common options

Option or formWhat it does
--staged, --cachedShow changes that are staged for the next commit
--statShow a summary of files and counts instead of every line
--name-onlyList only the names of changed files
-wIgnore whitespace changes
A..BCompare two branches or commits
--word-diffHighlight changed words instead of whole lines

Examples

See unstaged changes
git diff
See what you are about to commit
git diff --staged
Summarise changes against another branch
git diff --stat main...feature
app.js | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Compare one file between two commits
git diff 3f2a9c1 HEAD -- app.js
List changed file names only
git diff --name-only HEAD~3

Notes

See also

Last reviewed 2026-10-09.