How do I synchronize two branches in the same Git repository?

后端 未结 3 958
小鲜肉
小鲜肉 2021-01-31 03:03

Here\'s a common workflow hurdle I encounter often:

master is our \"stable\" branch

$ git status
# On branch master
nothing to commit (working         


        
3条回答
  •  长发绾君心
    2021-01-31 03:46

    I use the following to combine changes from two branches (mine and yours) and to synchronize both branches for continued work. This seems to be working. Does anyone see a problem with it?

    git checkout mine # make sure I'm on my branch
    git commit -a     # commit changes
    git push origin mine  
    git checkout yours # switch to your branch
    git pull origin yours # get changes you've committed & pushed
    git checkout mine 
    git merge yours # merge your changes into mine
    git push origin mine 
    git checkout yours 
    git rebase mine # set your branch to the merged result
    git push origin yours # push the merged result up to your branch on origin
    git checkout mine # get back to my branch
    

提交回复
热议问题