Home > Net >  How to change branch base in Git?
How to change branch base in Git?

Time:11-28

I have feature branch which was branched off of master. Let's call it feature1

There is another feature branch (let's call it feature2) created by another person.

I need to make my feature branch to be based on feature2.

What's the proper way to do this?

My understanding is that I have to:

git checkout feature1
git rebase --onto feature2 feature1

Is this correct?

And what about:

git checkout feature1
git rebase -i feature2

Which one is better? I mean, git rebase -i is interactive so at least I can see what commits will be included, so I guess that's safer?

CodePudding user response:

After the checkout,

git rebase feature2

should work just as well. The '-i' option you proposed as an alternative allows you to select the commits you want to include. It's not "safer": just different.

  • Related