在 Git 中合并两个远程存储库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1767980/
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
Merging two remote repositories in Git
提问by Readon Shaw
I want to merge two remote repositories in Git.
我想在 Git 中合并两个远程存储库。
One is mainstream repository, which I do not have write permission. I want to track its master branch.
一个是主流存储库,我没有写权限。我想跟踪它的主分支。
The other is maintained by us, I have full rights on it.
另一个由我们维护,我拥有完全的权利。
I want to track the mainstream code. At the same time, our modification would be recorded in my remote repository.
我想跟踪主流代码。同时,我们的修改会记录在我的远程仓库中。
How do I do this?
我该怎么做呢?
回答by VonC
I would recommend:
我会推荐:
- cloning
yourRemoteRepo
(that way, you can easily pull/push from that repo) adding
mainstreamRepo
as a remote and fetch its branch, then track the one which interest yougit clone git://yourRemoteRepo git remote add mainStreamRepo http://mainStreamRepo git fetch mainStreamRepo git checkout -b mainStreamMaster mainStreamRepo/master git checkout master
- 克隆
yourRemoteRepo
(这样,您可以轻松地从该存储库中拉/推) 添加
mainstreamRepo
为远程并获取其分支,然后跟踪您感兴趣的分支git clone git://yourRemoteRepo git remote add mainStreamRepo http://mainStreamRepo git fetch mainStreamRepo git checkout -b mainStreamMaster mainStreamRepo/master git checkout master
From there, you can
从那里,你可以
- merge
mainStreamMaster
to yourmaster
, - or rebase your
master
on top ofmainStreamMaster
(in order to integrate the full history ofmainStreamMaster
into yourmaster
branch) - then make some evolutions to
master
(or to a topic-specific branch) that you can push toyourRemoteRepo
.
- 合并
mainStreamMaster
到您的master
, - 或重新建立您
master
的基础mainStreamMaster
(以便将 的完整历史记录集成mainStreamMaster
到您的master
分支中) - 然后对
master
(或特定主题的分支)进行一些演变,您可以将其推送到yourRemoteRepo
.