How to move the current working branch to master branch in git

后端 未结 10 1040
挽巷
挽巷 2020-12-13 00:13

I have currently one of the project it contain more branches. master branch not yet merger long time. So i want switched to master with latest code.

Can you please g

10条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-13 00:41

    you need to merge your current branch into the master branch. the way i do it is:

    1) git fetch origin  # get all branches from server  
    2) git rebase master # update your local master to the origin master, in case master has changed upstream
    3) git checkout   # go to your branch
    4) git rebase master # rebase your branch to master; applies your branch's changes ontop of the master, where it diverged
    5) git checkout master # go back to master
    6) git merge  # merge your branch into master.  since you rebased, this should be trivial
    7) git push # push your master upstream
    

提交回复
热议问题