Git Diff
Compare working tree, index, branches, and commits precisely.
- git diff
- git diff staged
- diff stat
- word diff
- compare branches
Git Diff
Compare working tree, index, branches, and commits precisely.
Commands
| Command | What it does |
|---|---|
git diff | Unstaged changes (work tree vs index) |
git diff --staged | Staged changes (index vs HEAD) |
git diff main...HEAD | What the current branch adds vs main |
git diff <a> <b> --stat | File summary between two refs |
git diff --word-diff | Word-level diff for prose |
git difftool --dir-diff main HEAD | Open full-directory diff in a GUI tool |
Example
git diff --staged
git diff main...HEAD --stat
git diff v1.2.0 v1.3.0 -- src/
FAQ
diff vs diff --staged?
Plain git diff shows unstaged edits only; --staged (aka --cached) shows what the next commit would record.
What does triple-dot mean?
A...B compares B against the merge base of A and B — exactly what a PR would add.
よくある質問
diff vs diff --staged?
Plain git diff shows unstaged edits only; --staged (aka --cached) shows what the next commit would record.
What does triple-dot mean?
A...B compares B against the merge base of A and B — exactly what a PR would add.
Git
Git Config Essentials
Set identity, defaults, and aliases for Git on a new machine.
Git Clone and Init
Start a repo from scratch or copy a remote repository locally.
Git Add and Commit
Stage changes and record them as commits with clear messages.
Git Branch Basics
Create, list, rename, and delete branches for parallel work.