Git rebase one branch on top of another branch

前端 未结 4 1500
栀梦
栀梦 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条回答
  •  情话喂你
    2021-01-30 09:13

    First of all, you have to make sure your reference to Branch1 is up to date (specialy since it's history has been modified).

    If you like to work with local copys, you cand do something like this:

    git push origin Branch2 # this ensures you have at least one copy in your remote
    git fetch origin
    git checkout Branch1
    git reset --hard origin/Branch1
    git checkout Branch2
    git rebase Branch1 # solve conflicts ... and check that everything is ok
    git push -f origin Branch2
    

提交回复
热议问题