Consolidate fixup commits into clean logical commits before merge.
When to Use
- •Before merging a feature branch to main
- •After iterative development with multiple fixup commits
- •When commit history needs cleanup for review
Process
- •Verify clean working tree:
git status - •Create backup branch:
git branch backup-$(git branch --show-current)-$(date +%s) - •Show current commits:
git log --oneline origin/main..HEAD - •Run autosquash rebase:
bash
GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash origin/main
- •Verify result:
nix flake check - •Compare with backup:
git diff backup-*..HEADshould be empty - •Show final commits:
git log --oneline origin/main..HEAD
Manual Cleanup (requires user approval)
If autosquash rebase is not sufficient due to complex interleaved changes:
- •ASK USER for approval before proceeding with soft reset
- •
git reset --soft origin/main - •
git reset HEAD -- . - •Stage and commit in logical groups using
/commitskill - •Verify:
nix flake check
Soft reset rewrites history more aggressively than rebase. Only use when rebase cannot produce clean commits.
Principles
- •One logical change per final commit
- •Squash all fixups into their target commits
- •Drop commits that are immediately superseded
- •Preserve struggle documentation in code comments, not commit history
- •Separate CLAUDE.md changes from code commits
Rules
- •NEVER force push without user confirmation
- •NEVER delete backup branch automatically
- •ALWAYS verify nix flake check passes after rebase
- •ALWAYS show before/after commit list to user