git diff
Shows changes between commits, the working directory, and the staging area.
Syntax
git diff [<options>] [<commit>] [--] [<path>...]
Options
- --staged / --cached: Shows changes between staging area and last commit
- --stat: Shows a summary of changes (insertions/deletions per file)
- --name-only: Shows only the names of changed files
- --name-status: Shows names and status of changed files
- -w / --ignore-all-space: Ignores whitespace changes
Example
git diff git diff --staged git diff HEAD~2..HEAD git diff main..feature
Tip
Use git diff --staged to see what will be included in the next commit.