Search code examples
gitmergegit-branchbranching-and-merginggit-remote

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?


Solution

  • 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