Sameer Kamran
Sameer Kamran

Reputation: 247

Change Parent of a Branch

I have Branch a branch A checked out from master branch.then i have a branch B Checked out from branch A .

I want to change the parent of branch B to master

Current Tree

         master
        /
       A
      /
     B

Should Be

     master
     /   \
    A     B

Upvotes: 5

Views: 6802

Answers (2)

dasariarun
dasariarun

Reputation: 113

You can use this command to change your parent branch:

git rebase --onto new_parent_branch old_parent_branch

In your case, use these commands:

  1. git checkout B

  2. git rebase --onto master A

Upvotes: 5

Gary van der Merwe
Gary van der Merwe

Reputation: 9563

git checkout B
git rebase A --onto master

Upvotes: 10

Related Questions