Seeing What Changed - diff

git diff

git diff shows you the exact line-by-line changes between two states of your files - not just which files changed, but precisely what's different inside them. Which two states it compares depends entirely on the flags you pass:

CommandCompares
git diffWorking directory vs staging area (your unstaged edits)
git diff --stagedStaging area vs the last commit (exactly what you're about to commit)
git diff HEADWorking directory vs the last commit (everything uncommitted, staged or not)
git diff main featureTwo branches
git diff abc123 def456Two specific commits
git diff --statA short summary (files touched + line counts) instead of the full diff
$ git diff --staged
diff --git a/app.py b/app.py
index 3a1b2c4..7f8e9d0 100644
--- a/app.py
+++ b/app.py
@@ -1,2 +1,2 @@
-print('hi')
+print('hello world')

Reading a diff: a line starting with - existed before and was removed; a line starting with + is new. The @@ -1,2 +1,2 @@ line (a "hunk header") just tells you which line numbers this chunk of changes covers in the old and new versions - you can usually skim past it and focus on the +/- lines themselves.

Tip: Always run git diff --staged right before committing - it's your last chance to catch a stray debug print(), a hardcoded secret, or a file you didn't mean to include, before it becomes a permanent part of history.