How to View Changes in Git (git diff)
git diff shows the exact line-by-line differences between your working directory, the staging area, and the last commit.
Published September 28, 2026
git diff shows line-by-line changes between states: working tree vs staging, staging vs last commit, or any two commits and branches.
How it works
With no arguments it shows unstaged changes. --staged shows what will go into the next commit.
Compare branches with git diff main..feature or limit to a file path.
Try it
git diff
- const a = 1
+ const a = 2
git diff --staged
Practical examples
Unstaged changes
git diffStaged changes
git diff --stagedTwo branches
git diff main..feature --statOne file between commits
git diff a1b2c3 d4e5f6 -- src/app.jsCommon mistakes
- Expecting git diff to show staged changes.
- Ignoring whitespace noise (use -w).
- Not using --stat for a summary.
Key takeaways
- diff = unstaged, diff --staged = staged.
- Compare any two refs.
- --stat for an overview.
FAQ
How do I ignore whitespace?
git diff -w.
Show only filenames?
git diff --name-only.