Git History Hygiene
Required Rules
- •Treat one "work" as one goal-oriented work unit (usually one PR branch), not one commit.
- •Before starting a new work unit, run
git status -sbandgit log --oneline origin/main..HEAD. - •If unrelated commits or diffs are present, create a new branch from the latest
mainand carry only required diffs (for example: cherry-pick). - •Multiple commits are allowed within the same work unit.
- •Before creating a PR or requesting review, check again that unrelated diffs are not mixed.
Start-Of-Work Checks
- •Run
git status -sb. - •Run
git log --oneline origin/main..HEAD. - •If the worktree is clean and no unrelated commits are listed, continue.
- •If unrelated changes exist, move work to a clean branch from
main.
Pre-PR Checks
- •Run
git status -sb. - •Confirm only intended files are changed.
- •Run
git log --oneline origin/main..HEAD. - •Confirm only intended commits are included.