Workflow Git & Workflow

Clean Up Git History

Workflow for squashing and organizing commits before merge

githistorycleanup
CLAUDE.md

When cleaning up git history before merge:

  1. Count your commits since branching: git log --oneline main..HEAD.
  2. Interactive rebase to squash WIP commits: git rebase -i main.
  3. Keep commits that represent logical units of work. Squash “fix typo” and “WIP” commits into their parent.
  4. Write clear final commit messages that explain the why, not just the what.
  5. Force-push to your feature branch (never to shared branches): git push --force-with-lease.
  6. 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.

get crystl