Skip to content
The Git Crypt

/static/cripta/en/ossada/rebase-onto/

Menu

GIT-025 · Surgery

git rebase --onto

Cuts out a series of commits and grafts it onto another base.

A plain rebase moves a whole branch on top of another; --onto hands you the scalpel: three arguments say what to cut — the commits after <old-base> — and where to reimplant, <new-base>.

It is the command for the branch born in the wrong place: the topic built atop another topic that has since been merged, the series that must leave a condemned branch. One line, and only your commits cross to the new base, dragging none of the debris behind them.

$ git rebase --onto main servidor topico
Successfully rebased and updated refs/heads/topico.
The series cut from one bough and grafted onto another.