在Git中合并两个远程存储库 [英] Merging two remote repositories in Git
问题描述
我想在Git中合并两个远程存储库。
其中一个是主流存储库,我没有写入权限。我想跟踪它的主分支。
另一个由我们维护,我对它有完整的权利。
<我想跟踪主流代码。同时,我们的修改将记录在我的远程存储库中。
我该如何做?
我会建议: 添加
yourRemoteRepo
(这样,你可以很容易地从该回购中拉/推)
主流回收
作为远程和获取它的分支,然后跟踪你感兴趣的那个
git clone git:// yourRemoteRepo
git remote add mainStreamRepo http :// mainStreamRepo
git fetch mainStreamRepo
git checkout -b mainStreamMaster mainStreamRepo / master
git checkout master
从那里开始,您可以
master
,
mainStreamMaster
之上的master (为了将 mainStreamMaster
的完整历史记录集成到您的然后进行一些演变为
master
(或转到特定于主题的分支)您可以推送至 yourRemoteRepo
。
I want to merge two remote repositories in 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?
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
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
.
这篇关于在Git中合并两个远程存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!