Guide for breaking changes into logical, atomic commits using interactive staging. Use when committing changes that span multiple concerns, when needing to stage parts of files (hunks), when asked to create well-organized commit history, or when changes should be split into multiple commits.
Break changes into logical, atomic commits using interactive staging.
git status # overview of changed files
git diff # unstaged changes
git diff --cached # staged changes
git diff HEAD # all changes (staged + unstaged)
Look for natural boundaries: different features, bug fixes, refactors, or config changes.
Each commit should represent one logical change. Signs that changes belong in separate commits:
Common groupings:
git add <file> # stage entire file
git add <dir>/ # stage all files in directory
git reset HEAD <file> # unstage file
Use git add -p to stage specific hunks within a file:
git add -p # interactively stage hunks from all files
git add -p <file> # interactively stage hunks from specific file
Hunk commands:
y - stage this hunkn - skip this hunks - split into smaller hunks (if hunk contains multiple changes)q - quit, keeping already-staged hunks? - show helpgit diff --cached # review exactly what will be committed
Use the commit-message skill for formatting. Key points:
type(scope): descriptionAfter each commit:
git status # check remaining changes
git log --oneline -3 # verify commit was created
Continue staging and committing until all changes are organized into logical commits.