Merging multiple branches with git

拈花ヽ惹草 提交于 2019-12-02 17:09:42
  1. git checkout master
  2. git pull origin feature1 feature2
  3. git checkout develop
  4. git pull . master (or maybe git rebase ./master)

The first command changes your current branch to master.

The second command pulls in changes from the remote feature1 and feature2 branches. This is an "octopus" merge because it merges more than 2 branches. You could also do two normal merges if you prefer.

The third command switches you back to your develop branch.

The fourth command pulls the changes from local master to develop.

Hope that helps.

EDIT: Note that git pull will automatically do a fetch so you don't need to do it manually. It's pretty much equivalent to git fetch followed by git merge.

I would just "fetch" all of origin:

git fetch origin

now that it is in your repo you can merge the branches into master:

git checkout master

git merge origin/feature1 

git merge origin/feature2 

now you can merge master into develop

git checkout develop
git merge master 

if you are going to commit back to origin then I would setup a local tracking branch so you can have local access and push directly to origin:

git branch --track origin/feature1 feature1
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!