Git Rebase Cheat Sheet/Transplant a subset of commits

Move only part of a branch to a new base.

Section: Common Rebase Workflows

Transplant a subset of commits

bash
bash
git rebase --onto new-base old-base topic
Explanation

Classic advanced rebase pattern for moving a subset of commits that originally started after `old-base`.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Common Rebase Workflows
Rebase current branch onto main
Replay your branch on top of the latest main.
OpenIn sheetbashsame section
Fetch and rebase instead of merge
Update your current branch with a linear pull strategy.
OpenIn sheetbashsame section
Rebase with autostash
Temporarily stash dirty worktree changes before rebasing.
OpenIn sheetbashsame section
Rebase preserving merges
Maintain merge structure while rebasing.
OpenIn sheetbashsame section
Rewrite history from the root commit
Run interactive rebase from the start of the repository.
OpenIn sheetbashsame section
Interactive rebase last 3 commits
Edit the last 3 commits.
OpenIn sheetbash2 tag match