Merge two remote branches in a Git repository
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?
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
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.