Module 2 · Lesson 2 of 47/34 in the course~16 min
Module lessons (2/4)
Inspecting diffs: Working Tree vs Index vs Commits
Lesson preview5 hands-on exercises readyGit & Modern Collaboration · Module 2 — History Inspection, Diffs & Time Travel
Distinguish unstaged edits from staged snapshots using git diff and git diff --staged.
What you'll learn in this lesson
- Distinguish exact comparison boundaries between Working Tree vs Staging Index (
git diff) and Staging Index vsHEAD(git diff --staged). - Compare any working tree directly against
HEAD(git diff HEAD) or between two commits (git diff HEAD~1 HEAD). - Audit pending line patches before staging and before sealing every commit.
Overview
git status tells you which files changed, while git diff prints line-by-line patch hunks (- removed, + added).
Novice Git users often feel baffled when git diff prints nothing right after git add .! That happens because bare git diff checks the first gap (Working Tree vs Index), whereas git diff --staged checks the second gap (Index vs HEAD):
Sections covered in this lesson
- 1Three Trees, Two Comparison Boundaries
- 2Switch Diff Scopes Visually
Pro Lesson · Module 2 — History Inspection, Diffs & Time Travel
Unlock "Inspecting diffs: Working Tree vs Index vs Commits" and the full Git & Modern Collaboration curriculum
Distinguish unstaged edits from staged snapshots using git diff and git diff --staged.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Git & Modern Collaboration plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.