Seeing What Changed - diff
git diff
git diff shows line-by-line changes. Which changes depends on the flags:
| Command | Compares |
|---|---|
git diff | Working directory vs staging (unstaged changes) |
git diff --staged | Staging vs last commit (what you're about to commit) |
git diff HEAD | Working dir vs last commit (all uncommitted) |
git diff main feature | Two branches |
git diff abc123 def456 | Two commits |
git diff --stat | Summary (files + line counts) |
$ git diff --staged
diff --git a/app.py b/app.py
-print('hi')
+print('hello world')
Tip: Always git diff --staged right before committing - it's the last chance to catch a debug line, a secret, or a stray file you didn't mean to include.