Appearance
Fixup / Autosquash Quick Reference
bash
# Create a fixup commit targeting a specific SHA
git commit --fixup=abc1234
# Fixup the current HEAD
git commit --fixup=amend:
# Create a squash commit (preserves message for editing)
git commit --squash=abc1234
# Rebase and auto-arrange fixups
git rebase -i --autosquash HEAD~10
# With the config set (recommended)
git config --global rebase.autoSquash true
git rebase -i HEAD~10 # same effect without --autosquash
# Autosquash with autostash for dirty tree
git rebase -i --autosquash --autostash HEAD~5
# One-liner: squash the whole branch against upstream
git rebase -i --autosquash --onto $(git merge-base HEAD @{upstream})CI gate: detect fixup commits
bash
# Check for fixup commits on a feature branch
git log --oneline --grep="^fixup!" origin/main..HEAD
if [ $? -eq 0 ]; then
echo "Fixup commits found. Run rebase --autosquash before merging."
exit 1
fi
# Pre-receive hook snippet
while read oldsha newsha ref; do
git rev-list "$oldsha".."$newsha" 2>/dev/null | \
xargs git log --no-walk --oneline --grep="^fixup!" && exit 1
doneVerify after squash
bash
# Capture tip, squash, then range-diff
git rev-parse HEAD > /tmp/pre-squash
git rebase -i --autosquash HEAD~10
git range-diff $(cat /tmp/pre-squash)..$(cat /tmp/pre-squash) HEAD..HEADFilter fixup out of log searches
bash
git log --grep="feature" --invert-grep --grep="^fixup!"Config key
| Key | Values | Effect |
|---|---|---|
rebase.autoSquash | true / log / false | Auto-arrange fixup/squash commits during interactive rebase |
rebase.autoStash | true / false | Auto-stash dirty working tree before rebase |
See also
docs/devops-workflows/git-fixup-autosquash.mddocs/devops-workflows/git-range-diff.mdscripts/fixup-autosquash-manage.sh