git diff
Show file differences between working directory, staging area, and commits
Syntax
git diff [<options>] [<commit>] [--] [<path>...]
Parameters
| Parameters | Description | Examples | Level |
|---|---|---|---|
--staged |
New ( --cached) | |
Common |
--stat |
|
Common | |
--name-only |
|
Common | |
--word-diff |
Level | |
Common |
--color-words |
|
Common | |
-b |
|
Common |
Examples
git diff
git diff --staged
3
git diff HEAD~3
git diff main..feature
git diff --stat
src/app.js | 12 ++++++------
src/util.js | 3 ++-
2 files changed, 8 insertions(+), 7 deletions(-)
git diff -- src/login.js
Tips
- git diff --staged
- Code Review git diff main.feature-branch
- git diff --name-only
- difftool : git difftool --tool=vscode