📝
This post is part of my “Shorts” series, where each post is concise and hyper-focused on a single concept.

Apart from the interactive mode of git-rebase, you can also use the --onto flag to change the current base of your feature branch.

Command

git rebase --onto <newBase> <oldBase> <featureBranch>

What does it do?

Consider the scenario below:

Let’s say that you don’t want featureB branch to be based off featureA, but you want it to be branched off the main branch, as shown below:

The --onto flag will help you to change the base of featureB branch from featureA to main. The command that you need to use will be:

git rebase --onto main featureA featureB

Sources