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

CommandWhat it does
git diffUnstaged changes (work tree vs index)
git diff --stagedStaged changes (index vs HEAD)
git diff main...HEADWhat the current branch adds vs main
git diff <a> <b> --statFile summary between two refs
git diff --word-diffWord-level diff for prose
git difftool --dir-diff main HEADOpen 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.

Întrebări frecvente

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