Git

Lesson 03

Atomic commits and messages

Keep commits small enough to review and give each one a message that explains the user-facing or maintenance reason.

Good Code

commit-plan.sh
# One commit explains one behavior change.
git add components/lesson/lesson-pager.tsx
git commit -m "improve lesson navigation controls"

# A separate commit keeps test intent easy to review.
git add tests/content/navigation.test.ts
git commit -m "cover lesson navigation boundaries"

Bad Code

commit-plan.sh
# Reviewers cannot tell which concern this commit owns.
git add .
git commit -m "work"
git push

Review Notes

What to review

Good Code

The good version separates UI behavior from test coverage and gives each commit a message that explains the change.

Bad Code

The bad version creates a grab-bag commit. Reviewers have to understand unrelated edits at once, and reverting one part becomes riskier.

Takeaways

  • A commit should describe one coherent change and make the reason visible without reading the whole diff first.