Overview
An atomic commit holds exactly one logical change (one fix, one feature, or one refactor), builds and passes tests on its own, and reverts cleanly. Split work this way before opening a pull request, because review, git bisect, and emergency reverts all assume each commit stands alone. Size does not matter: a 500-line refactor is atomic if every line serves the same change.
Rules
- Keep refactors separate from behavior changes. A typo fix bundled into a schema migration makes the commit unbisectable.
- Squash work-in-progress commits before merging to a shared branch. Stage selectively with
git add -p. - Give each commit a conventional-commits message so its type is visible in history.
refactor(auth): extract token-validation helper
fix(auth): reject expired tokens at the edge
Related
- git: staging, squashing, and history cleanup.
- conventional-commits: the message format that pairs with atomic commits.
- git-commands: staging, squashing, and bisect commands.
- github: pull requests review commits one at a time.
- general-principles: the broader case for small, reversible changes.