Git rebase one branch on top of another branch

前端 未结 4 1499
栀梦
栀梦 2021-01-30 08:44

In my git repo, I have a Master branch. One of the remote devs created a branch Branch1 and had a bunch of commits on it. I branched from Branch1

4条回答
  •  梦毁少年i
    2021-01-30 08:56

    git rebase branch1 branch2 will rebase branch branch2 onto branch1. Operationally, this means any commits which are contained only in branch2 (and not in branch1) will be replayed on top of branch1, moving the branch2 pointer with them. See git rebase --help for more information, including diagrams of this operation.

    The operation might produce some conflicts which then you'll have to resolve manually. Edit the affected files, merging content and removing any failed hunks. Afterwards, mark the files as merged using git add and then continue the rebase using git rebase --continue. Repeat until it is done.

    Once done, you have nothing else to do. You don't have to push. However if you wish to mirror your new changes to some other repository (for instance, to share it with others or to have those changes in another repository of yours), do a final git push.

提交回复
热议问题