合并 Git 存储库中的两个远程分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28163022/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Merge two remote branches in a Git repository
提问by Sai Ye Yan Naing Aye
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?
我想将development
分支合并到production
(主)分支中。任何人都可以共享用于合并两个远程分支的 Git 命令吗?
回答by charlierproctor
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
回答by zizhen zhan
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.
为什么需要临时分支而不应该使用本地开发?因为你本地的开发可能和远程的不一样。