git rebase -i HEAD~3Opens the todo list so you can reorder, squash, edit, or drop commits.
Advanced rebase commands, interactive workflows, conflict handling, and branch-transplant patterns.
Open, edit, and manage interactive rebase sessions.
git rebase -i HEAD~3Opens the todo list so you can reorder, squash, edit, or drop commits.
git rebase --edit-todoHelpful when you need to change the sequence or actions after the rebase has already started.
git rebase --show-current-patchUseful when a rebase stops on a conflict and you want to see the exact patch Git is trying to apply.
git rebase --continueStandard next step after resolving conflicts and staging the intended resolutions.
git rebase --abortUse this when the rebase becomes too messy or you want to restart with a different strategy.
git rebase --skipOnly use when you intentionally want to drop the stopped patch from the rebased history.
Common todo-list actions used in interactive rebase.
pick a1b2c3d Commit message`pick` is the default action and applies the commit as a normal rebased commit.
reword a1b2c3d Commit messageUse `reword` when the commit content is correct but the message needs cleanup.
edit a1b2c3d Commit messageUse `edit` when you need to change the commit content, split the commit, or otherwise manipulate it mid-rebase.
squash d4e5f6g Follow-up fix`squash` merges the commit into the previous one and opens an editor to combine messages.
fixup d4e5f6g Follow-up fixIdeal when the follow-up commit should disappear into the previous commit without preserving its message.
drop badc0de Temporary experimentUse `drop` carefully because it removes the commit from the resulting branch history.
Typical advanced rebasing patterns.
git rebase mainKeeps feature history linear by replaying it on top of another branch tip.
git pull --rebaseOften preferred for keeping local history clean when syncing with a tracking branch.
git rebase --onto new-base old-base topicClassic advanced rebase pattern for moving a subset of commits that originally started after `old-base`.
git rebase -i --rootUseful for cleaning very early history or splitting an initial commit in private repositories.
git rebase --autostash mainHelpful when your working tree is not clean but you still need to rebase.
git rebase --rebase-merges mainA more advanced option when branch history contains meaningful merges that should not be flattened.
Diagnose and recover from difficult rebase situations.
git statusGit status gives the clearest view of what remains to be resolved during a paused rebase.
git config --global rerere.enabled trueA strong quality-of-life improvement for repeated rebases or long-lived branches.
git checkout --ours path/to/file && git add path/to/fileUseful in conflict resolution when you intentionally want your branch version of a path.
git checkout --theirs path/to/file && git add path/to/fileUseful in conflict resolution when the rebased-on branch version should win for a path.
git reflog | head -20Reflog is usually the fastest recovery path when a rebase result is not what you wanted.