Lesson 9 / 26
diff & log
See exactly what changed, and browse the project's history.
git diff
Shows line-by-line changes not yet staged. Add --staged to see what's already in the staging area.
git diff
git diff --staged
Output:
-const port = 3000; +const port = 8080;
git log
Browse commit history — author, date, message, and a unique hash for each commit.
git log --oneline -5
Output:
a1b2c3d Add landing page markup 9f8e7d6 Initial commit
Quick check: Which command shows staged changes not yet committed?
- git diff
- git diff --staged
- git log
Answer
git diff --staged — Plain `git diff` compares working directory to the staging area; `--staged` compares staging area to the last commit.