Merge two remote branches in a Git repository
Asked Answered
A

2

60

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?

Aniela answered 27/1, 2015 at 4:0 Comment(0)
D
95

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
Drubbing answered 27/1, 2015 at 5:36 Comment(3)
First do I clone production branch?Aniela
@ charlierproctor you right but i have some files, these are both changes and not merge.Any suggestion?Aniela
It sounds like you are running into merge conflicts. Unfortunately, you need to manually resolve these issues. Open up the files where the conflicts occur and manually resolve the conflicts. When you're done, add and commit.Drubbing
L
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.

Langur answered 23/12, 2019 at 2:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.