Keep Commits Small Enough to Revert Safely
Scenario
Compare two ways of committing a booking boundary fix and a separate quiz-scorer feature.
Try it yourself
Choose each commit history to see what happens if the quiz feature needs a rollback.
| Case | Result |
|---|---|
| 1 commit: "fix booking bug + add quiz scorer + tweak CSS" | Select a choice above to see what happens. |
| Commit 1: code fix only; Commit 2: test added next day | Select a choice above to see what happens. |
| Commit 1: "Fix booking 0-seat boundary + test"; Commit 2: "Add quiz scorer + tests" | Select a choice above to see what happens. |
Reveal the explanation
- 1 commit: "fix booking bug + add quiz scorer + tweak CSS"
Hard to revert! Rolling back the broken quiz feature also reintroduces the booking bug.
- Commit 1: code fix only; Commit 2: test added next day
Incomplete snapshot. Commit 1 cannot prove itself if inspected alone.
- Commit 1: "Fix booking 0-seat boundary + test"; Commit 2: "Add quiz scorer + tests"
Clean & reversible! Either commit can be reverted independently in seconds.
Pair each small behavior change with its matching tests in one atomic commit and write a clear message stating what changed and why.
Your turn
Split three pending changes (negative-seat guard, library limit constant, README typo) into clean atomic commit titles.
Common mistake Bundling all three into one commit called "updates".
Check your work
Commit 1: Reject negative freeSeats with INVALID_FREE_SEATS; Commit 2: Extract MAX_BORROWED_BOOKS constant; Commit 3: Fix README typo.
Quick check
This browser could not save your progress. Changes last until you leave the page.