git change the parent branch

前端 未结 2 669
孤独总比滥情好
孤独总比滥情好 2021-01-28 12:16

The short story is : I have created Branch A out from the Develop Branch then I created Branch B From Branch A

相关标签:
2条回答
  • 2021-01-28 12:56

    Let's say that your current branch diagram looks something like this:

    develop: A -- B
                   \
    branchA:        C -- D -- E
                               \
    branchB:                    F -- G
    

    You want the B branch to look like this:

    develop: A -- B
                   \
    branchB:        F -- G
    

    Rebase onto can be used here:

    git rebase --onto B E
    

    In plain English terms, the above command says to place the commit whose parent is E, which is the F commit (and the start of the B branch) onto a new base which is commit B in the develop branch.

    0 讨论(0)
  • 2021-01-28 13:13

    You are looking for git rebase --onto, since what you want to do is basically rebase only the commits from branch B onto develop.

    There is a very good description of rebasing in the official git documentation. See section More Interesting Rebases for an example like yours.

    Your example would be solved by git rebase --onto develop branchA branchB.

    Also see the git rebase documentation.

    0 讨论(0)
提交回复
热议问题