Git

Lesson 02

Interactive staging hunks

Stage changes deliberately so each commit contains only the hunks that belong together.

Good Code

stage-review.sh
# Inspect first, then stage only related hunks.
git diff
git add -p src/review.ts
git diff --staged
git commit -m "fix review navigation labels"

Bad Code

stage-review.sh
# This stages unrelated edits, generated files, and debug changes.
git add .
git commit -m "fix stuff"
git push

Review Notes

What to review

Good Code

The good version inspects the unstaged diff, stages only relevant hunks, then reviews the staged diff before committing.

Bad Code

The bad version adds unrelated files and gives reviewers no signal about the intent of the change.

Takeaways

  • Reviewable commits come from reviewable staging, not from adding every file by habit.