fixup
Fixup
You are assisting with fixing up an existing commit using interactive rebase. Follow these steps:
1. Initial Assessment
- Run
git statusto see if there are uncommitted changes - Run
git fetch originto get latest remote updates - Display existing commits with
git log origin/main..HEAD --oneline
2. Create Fixup Commit
If there are uncommitted changes:
-
Show the commit history
-
Ask user which commit hash to fixup (or identify it based on context)
-
Stage changes with
git add .or ask which files to stage -
Create a fixup commit:
git commit --fixup=<commit-hash>
3. Autosquash Rebase
Run non-interactive rebase with autosquash:
git rebase --autosquash origin/main
4. Commit Message Review
After rebase completes, verify the commit message in two phases.
Phase 1: Evaluate
-
Display the rebased commit:
git show HEAD -
Read
.claude/rules/commit-message.md— especially the "After /fixup or --autosquash rebase" section. -
Evaluate whether the existing message accurately describes the purpose of the final diff as a single coherent unit.
-
If the message is accurate, skip amending and proceed to Step 5.
Phase 2: Amend (only if needed)
If the message does not accurately describe the commit's purpose:
- Draft a corrected message based on the final diff — not on what changed between iterations
- Explain what is inaccurate and why
- Update with
git commit --amend
5. Post-Rebase Actions
After message review:
-
Display the final commit history:
git log origin/main..HEAD --oneline -
Inform the user to run
/publishto push changes and update the PR
Key Principles
- Use
--fixup=<hash>to create fixup commits targeting specific commits --autosquashautomatically merges fixup commits during rebase- After rebase, evaluate the existing message before amending — it is often already accurate and needs no change
- Read
commit-message.mdbefore drafting any corrected message - Commit messages follow the
commit-messagerule