Summary: Commit hygiene
The big idea
Section titled “The big idea”A commit is a snapshot with intent. The mechanics from L2 plus the discipline from L3 produces a history that earns its existence.
Five rules for a subject line
Section titled “Five rules for a subject line”- Under 50-72 characters
- Imperative mood (
Add ...,Fix ..., notAdded ...orAdds ...) - Capitalized first letter
- No trailing period
- Subject answers WHAT; body answers WHY
Atomic commit principle
Section titled “Atomic commit principle”One logical change per commit. Test: if the subject uses “and”, “also”, “plus”, split into separate commits. The staging area is the tool that lets you do this when working-directory changes are mixed.
Conventional Commits at a glance
Section titled “Conventional Commits at a glance”<type>(<scope>): <description>
feat: new featurefix: bug fixdocs: documentationrefactor: code restructure, no behavior changetest: test changeschore: maintenanceperf: performancestyle: formatting onlyAdopt when team or open-source project uses it; skip for solo projects unless using semantic-release tooling.
Common anti-patterns
Section titled “Common anti-patterns”- Vague verbs (
fix,update,WIP) - Kitchen-sink commits (many unrelated changes)
- End-of-day megacommits
- Fix-the-previous-commit cascades
- Body-less commits on complex changes
The cost equation
Section titled “The cost equation”Writing well costs 1 minute. Reading badly costs 1 hour. The math favors writing well by ~60x. Apply this to every commit.
What you carry into L4
Section titled “What you carry into L4”You can now make good commits. L4 teaches how to fix bad ones, git reset vs git revert vs git restore, plus reflog as your safety net.
Voice anchor
Section titled “Voice anchor”Git stores snapshots. Every other command is just navigating those snapshots.
A commit is a snapshot with intent. Make snapshots that earn their existence.