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.
Open the rebase todo list while a rebase is in progress.
git rebase --edit-todoHelpful when you need to change the sequence or actions after the rebase has already started.
Inspect the patch currently being replayed.
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.
Resume the rebase once conflicts are fixed.
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.
Replay the commit but edit its message.
reword a1b2c3d Commit messageUse `reword` when the commit content is correct but the message needs cleanup.
Replay the commit and pause so you can modify it.
edit a1b2c3d Commit messageUse `edit` when you need to change the commit content, split the commit, or otherwise manipulate it mid-rebase.
Combine two commits and merge their messages.
squash d4e5f6g Follow-up fix`squash` merges the commit into the previous one and opens an editor to combine messages.
Combine commit into previous commit and discard this commit message.
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.
Replay your branch on top of the latest main.
git rebase mainKeeps feature history linear by replaying it on top of another branch tip.
Update your current branch with a linear pull strategy.
git pull --rebaseOften preferred for keeping local history clean when syncing with a tracking branch.
Move only part of a branch to a new base.
git rebase --onto new-base old-base topicClassic advanced rebase pattern for moving a subset of commits that originally started after `old-base`.
Run interactive rebase from the start of the repository.
git rebase -i --rootUseful for cleaning very early history or splitting an initial commit in private repositories.
Temporarily stash dirty worktree changes before rebasing.
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.
Inspect rebase state and unresolved files.
git statusGit status gives the clearest view of what remains to be resolved during a paused rebase.
Reuse recorded conflict resolutions in future rebases and merges.
git config --global rerere.enabled trueA strong quality-of-life improvement for repeated rebases or long-lived branches.
Resolve one conflicted path using the current branch side.
git checkout --ours path/to/file && git add path/to/fileUseful in conflict resolution when you intentionally want your branch version of a path.
Resolve one conflicted path using the incoming side.
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.
Locate the branch state before an unwanted rebase.
git reflog | head -20Reflog is usually the fastest recovery path when a rebase result is not what you wanted.