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 form | What it does |
|---|---|
--staged, --cached | Show changes that are staged for the next commit |
--stat | Show a summary of files and counts instead of every line |
--name-only | List only the names of changed files |
-w | Ignore whitespace changes |
A..B | Compare two branches or commits |
--word-diff | Highlight changed words instead of whole lines |
Examples
git diff
git diff --staged
git diff --stat main...feature
app.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
git diff 3f2a9c1 HEAD -- app.js
git diff --name-only HEAD~3
Notes
- With no options, git diff does not show staged changes. Add --staged for those.
- Three dots (main...feature) compare from where the branches split, which is what a pull request shows. Two dots compare their tips.
- Untracked files do not appear in diff until they are added.
See also
Last reviewed 2026-10-09.