Best Practices
Atomic Commits
Keep each commit focused on one logical change to simplify review and rollback.
- Individuals or teams who want more predictable Git habits
- Maintainers setting collaboration expectations
- At least one real collaboration loop
- Basic command familiarity without a stable routine yet
- Treating guidance as absolute law without context
- Memorizing process without understanding team boundaries
Why atomic commits are not just aesthetics
An atomic commit is not about making history look neat. It is about making each commit explainable, reviewable, and reversible on its own.
Once one commit mixes multiple intentions, every downstream workflow gets heavier:
- reviewers must mentally separate concerns first
- revert becomes much riskier
- cherry-pick is more likely to drag unrelated work along
- incident analysis gets murkier
That is why atomic commits are a collaboration practice, not a cosmetic one.
1. One commit should answer one question
A practical test is not “how many files changed?” but “do these changes belong to the same intent?”
Good candidates for one commit:
- fixing empty email validation
- renaming a set of fields consistently
- adding tests directly tied to one behavior change
Poor candidates for one commit:
- bugfix plus style polish
- refactor plus behavior change
- formatting cleanup mixed with product logic
2. Three questions before you commit
Ask yourself:
- Can I summarize this commit in one sentence?
- Would reverting only this commit be relatively safe?
- Could a reviewer understand the intent from this commit alone?
If two of those answers are unclear, the commit is usually still too broad.
3. Split staging is often the real skill
The most useful tool here is still:
git add --patch
Its value is that it moves boundary-setting earlier, into staging, instead of hoping the boundary will magically become clear after the commit already exists.
4. Atomic commits directly improve review, revert, and cherry-pick
Review
Reviewers can react to the actual change instead of first untangling it.
Revert
A one-intent commit is much closer to surgical rollback.
Cherry-pick
Small focused fixes are far easier to transplant into another branch without collateral damage.
5. A lightweight team baseline
If the team has no standard yet, this is already enough:
- one commit, one intent
- do not mix refactor and behavior change without a good reason
- inspect
git diff --stagedbefore committing - when in doubt, split smaller
That last check is still one of the highest-value habits:
git diff --staged