TIL NOTE #024
One Thing Per Commit
Bad commit:
commit abc1234 - Add dark mode feature - Fix auth bug - Refactor database layer - Update docsSix months later, a feature breaks. You git bisect. The commit that introduced it also has four other changes. Which one broke it? Unknown.
Good commits:
commit abc1234 Add dark mode CSS variables
commit abc1235 Wire dark mode toggle to localStorage
commit abc1236 Fix auth token expiry bug
commit abc1237 Refactor database connection poolEach commit is atomic — it does one thing. You can revert it, cherry-pick it, understand it.
Commit messages that work:
✔ Add dark mode toggle to settings
✔ Fix race condition in token refresh
✔ Extract cache layer to separate module
✗ wip
✗ fix stuff
✗ checkpoint
Discipline compounds. One thing per commit. Bisect catches bugs in seconds. The blame is clear. New developers can read the history.
Commit early, commit often. One thing at a time.