在Git中合并两个远程存储库 [英] Merging two remote repositories in Git

查看:297
本文介绍了在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




从那里开始,您可以


  • code> mainStreamMaster 添加到您的 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 you

    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 your master,
  • or rebase your master on top of mainStreamMaster (in order to integrate the full history of mainStreamMaster into your master branch)
  • then make some evolutions to master (or to a topic-specific branch) that you can push to yourRemoteRepo.

这篇关于在Git中合并两个远程存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆