Clean Up Git History
Workflow for squashing and organizing commits before merge
CLAUDE.md
When cleaning up git history before merge:
- Count your commits since branching:
git log --oneline main..HEAD. - Interactive rebase to squash WIP commits:
git rebase -i main. - Keep commits that represent logical units of work. Squash “fix typo” and “WIP” commits into their parent.
- Write clear final commit messages that explain the why, not just the what.
- Force-push to your feature branch (never to shared branches):
git push --force-with-lease. - Verify CI passes on the cleaned-up branch before merging.
Copy this workflow into your CLAUDE.md or agent config file so your agent follows this process automatically.