Skip to content

Interactive Rebase Quick Reference ​

Core command ​

git rebase -i HEAD~N     # Rebase last N commits
git rebase -i <base>     # Rebase onto base (usually main)
git rebase -i --root     # Rebase entire history

Todo list operations ​

ShortFullEffect
ppickUse commit as-is
rrewordKeep content, edit message
eeditStop to amend content or split
ssquashCombine into previous, merge messages
ffixupCombine into previous, discard message
xexecRun shell command (non-zero = stop)
ddropRemove commit entirely
bbreakStop rebase for manual inspection

Useful flags ​

git rebase -i --autosquash     # Auto-place fixup! commits after targets
git rebase -i --exec "cmd"     # Run command after every commit
git rebase -i --rebase-merges  # Preserve merge topology
git rebase -i --empty=drop     # Drop commits that become empty
git rebase -i --update-refs    # Update stacked branch refs
git rebase -i -X theirs        # Auto-resolve conflicts with rebased side

Recovery ​

git rebase --abort          # Abort and return to original state
git rebase --continue       # After resolving conflict or editing
git rebase --skip           # Skip the current commit
git reset --hard ORIG_HEAD  # Recovery after completed rebase

CI patterns ​

# Gate every commit with lint
git rebase -i --exec "npm run lint" origin/main

# Auto-squash and verify
git rebase -i --autosquash --exec "npm test" main

Config ​

ini
[rebase]
    autoSquash = true
    autoStash = true
    updateRefs = true
    missingCommitsCheck = warn
    stat = true

Git Master — Git Reference for Every Skill Level