58

I have one remote repository with many branches. For example, my repository name is:

http://navis.com/MyRepo.git

Its branches are:

development
production (master)
testing

I would like to merge the development branch into the production (master) branch. Can anybody share a Git command for merging two remote branches?

DavidRR
  • 18,291
  • 25
  • 109
  • 191
Sai Ye Yan Naing Aye
  • 6,622
  • 12
  • 47
  • 65

2 Answers2

90

If you have remote-tracking branches set up locally, it's as simple as:

git checkout production
git merge development
git push origin production

If you have not yet set up remote-tracking branches, you could do something like:

git fetch origin
git checkout production     # or `git checkout -b production origin/production` if you haven't set up production branch locally
git merge origin/development
git push origin production
charlierproctor
  • 1,132
  • 9
  • 11
5

you can do this like:

git pull origin development:temp
git push origin temp:production

Why a temp branch is need and you should not to use the local development? Because your local development may not be the same as the remote one.

zizhen zhan
  • 200
  • 3
  • 6