I have 2 local branches called “develop” and “master”; they are similar. On my company’s server there’s one “main” repo (production) and several branches that were made by other developers:
$ git branch -a * develop master remotes/origin/HEAD -> origin/master remotes/origin/some-test remotes/origin/feature1 remotes/origin/feature2 remotes/origin/master
How can I merge remotes/origin/feature1 and remotes/origin/feature2 into my local “master” branch, copy that all into “develop” and start working with actual code in my “develop” branch?
git checkout mastergit pull origin feature1 feature2git checkout developgit pull . master(or maybegit rebase ./master)The first command changes your current branch to
master.The second command pulls in changes from the remote
feature1andfeature2branches. 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
developbranch.The fourth command pulls the changes from local
mastertodevelop.Hope that helps.
EDIT: Note that
git pullwill automatically do afetchso you don’t need to do it manually. It’s pretty much equivalent togit fetchfollowed bygit merge.