Git Rebase --onto
•1 min read
Today I learned about git rebase --onto, which is super useful for moving a branch to a different base.
The Problem
Say you created a feature branch off develop, but now you need to base it off main instead.
The Solution
bash
git rebase --onto main develop feature-branchThis takes all commits from feature-branch that came after develop and replays them on top of main.
The Syntax
bash
git rebase --onto <new-base> <old-base> <branch>new-base: Where you want the branch to be based onold-base: Where the branch is currently based onbranch: The branch you want to move
Super handy! 🎯
Related Posts (3)
Discover how git worktrees let you work on multiple branches simultaneously without the hassle of git stash—perfect for juggling features, hotfixes, and code reviews.
Jan 4, 2026
How to use Next.js's connection() API to opt specific components into dynamic rendering while keeping the rest of your page statically generated.
Feb 16, 2026