branch-discipline
Branch Discipline — Always Return to Main After Feature Work
Section titled “Branch Discipline — Always Return to Main After Feature Work”After finishing work on a feature/bug/refactor branch (committed, pushed, PR merged), you MUST:
- Switch back to the primary branch —
mainfor normal repos; the worktree’s intended branch for worktrees. - Pull the latest —
git fetch && git pull --ff-onlyso your local matches origin. - Delete the merged branch locally —
git branch -D <branch>(use-Dnot-dbecause squash-merge produces a new SHA so git’s ancestry check sees the branch as “not merged”). - Verify clean state —
git status --shortshould be empty. - Confirm in the report — explicitly state “back on main, working tree clean.”
Worktree exception: if the branch has a + prefix in git branch, it is in active use in a worktree — DO NOT delete it. Report as “in worktree, left untouched.”
Full worked example, multi-kit loop, and “when NOT to delete” cases: docs/branch-discipline.md.
Stale local branches cause the next git pull --ff-only to fail (local has commits main doesn’t), masking that work was already merged.