git rebase --onto: move the right commits to a new base

git rebase --onto: move the right commits to a new base

git rebase --onto looks like a complicated variation of git rebase. I avoided it for a long time for that reason. Yet this option answers a very specific question: how do you move only part of a branch to a new base without bringing along the commits below it? This happens when a branch was created from the wrong branch, a branch stack needs to be reorganized, or a few useful commits are trapped in the middle of a history. A standard rebase chooses what to replay implicitly. With --onto, you explicitly define the new base, the boundary of the commits to exclude, and the branch to move. ...

September 8, 2026 · 8 min · Anthony

Newsletter

Get new articles delivered straight to your inbox.

No spam. Unsubscribe in one click.