A TL;DR guide for git history transplant
Update: check out a new shorter version here!

Documentation
Original documentation:
git rebase [-i | --interactive] [<options>] [--exec <cmd>] [--onto <newbase> | --keep-base] [<upstream> [<branch>]] git rebase [-i | --interactive] [<options>] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
My “easy to remember” documentation:
git rebase [--onto <new_base>] [<old_base> [<last_commit>]]
Input
This is the initial git history we will use as example.
A-B-C-D master \ E-F-G feature* (current branch)
Output
Here are different ways to use git rebase --onto
. I will show the commands and the resulting history below.
- Rebase onto top of master:
git rebase --onto D git rebase master
A-B-C-D master \ E-F-G feature*
- Rebase onto inside of master:
git rebase --onto C
A-B-C-D master \ E-F-G feature*
- Rebase onto inside of master, start from inside of feature:
git rebase --onto C E git rebase --onto C F~1
A-B-C-D master \ F-G feature* (E disappeared)
- Rebase onto inside of master, start from & end inside of feature:
git rebase --onto C E F
A-B-C-D master \ F feature* (E and G disappeared)
That’s it. Enjoy !