Lesson 1: The Detective
Every great detective reconstructs the crime scene from evidence. In Git, the commit history is your evidence trail. It tells you exactly what changed, when it changed, and who changed it.
Reading the Crime Report: git log
The git log command shows the complete history of commits:
commit a1b2c3d4e5f6 (HEAD -> main)
Author: DevOps Cadet <cadet@cloudcorp.com>
Date: Mon May 19 10:00:00 2025
Fix database connection timeout
commit f6e5d4c3b2a1
Author: Senior Dev <senior@cloudcorp.com>
Date: Sun May 18 22:30:00 2025
Add user authentication module
Each commit shows:
- Hash — The unique ID (like a fingerprint).
- Author — Who made the change.
- Date — When it happened.
- Message — What was changed and why.
Compact View: git log --oneline
For a quick overview:
git log --oneline
a1b2c3d Fix database connection timeout
f6e5d4c Add user authentication module
9876543 Initial commit
Visual History: git log --graph
See the branch structure:
git log --oneline --graph --all
* a1b2c3d (HEAD -> main) Fix timeout
| * e4f5g6h (feature/login) Add login page
|/
* f6e5d4c Add auth module
* 9876543 Initial commit
Spotting Changes: git diff
git diff shows exactly what lines were added or removed:
- const timeout = 5000;
+ const timeout = 30000;
- Red lines (-) — Removed.
- Green lines (+) — Added.
Variants of git diff
| Command | Shows |
|---------|-------|
| git diff | Changes in working directory (not staged) |
| git diff --staged | Changes that are staged (ready to commit) |
| git diff HEAD~1 | Changes since the last commit |
| git diff branch1 branch2 | Differences between two branches |
booting...
Mission Objective
Investigate the project history:
- Read the full report: Run
git logto see the complete history. - Quick scan: Run
git log --onelinefor a compact summary. - Spot the changes: Run
git diffto see any uncommitted modifications.