Diffing

Diffing

Show unstaged changes

$ git diff

Compares working tree against the index (staged snapshot).

Show staged changes

$ git diff --staged

Compares the index against the last commit — shows what will go into the next commit.

Compare two branches

$ git diff main feature/name

Shows all differences between the tips of both branches.

Compare two commits

$ git diff abc1234 def5678

Show changes introduced by a single commit

$ git diff HEAD~1 HEAD

Or use git show for the same result with commit metadata:

$ git show HEAD

Diff a specific file

$ git diff -- path/to/file
$ git diff --staged -- path/to/file

Diff with statistics only

$ git diff --stat main feature/name

Shows a summary of changed files and line counts without the full patch.

On this page