Merge two remote branches in a Git repository

GitMergeGit BranchBranching and-MergingGit Remote

Git Problem Overview


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?

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSai Ye Yan Naing AyeView Question on Stackoverflow
Solution 1 - GitcharlierproctorView Answer on Stackoverflow
Solution 2 - Gitzizhen zhanView Answer on Stackoverflow