Merge two remote branches in a Git repository

Sai Ye Yan Naing Aye picture Sai Ye Yan Naing Aye · Jan 27, 2015 · Viewed 58.2k times · Source

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?

Answer

charlierproctor picture charlierproctor · Jan 27, 2015

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