I'd like to rebase to a specific commit, not to a HEAD of the other branch:
A --- B --- C master
\
\-- D topic
to
A --- B --- C master
\
\-- D topic
instead of
A --- B --- C master
\
\-- D topic
How can I achieve that?
Use the "onto" option:
Since rebasing is so fundamental, here's an expansion of Nestor Milyaev's answer. Combining jsz's and Simon South's comments from Adam Dymitruk's answer yields this command which works on the
topic
branch regardless of whether it branches from themaster
branch's commitA
orC
:Note that the last argument is required (otherwise it rewinds your branch to commit
B
).Examples:
So the last command is the one that I typically use.