简体   繁体   English

git fork repo到同一个组织

[英]git fork repo to same organization

How do I fork a repo in my organization into the same organization so that I can regularly sync the fork with the upstream repository? 如何将组织中的repo分叉到同一个组织中,以便我可以定期将fork与上游存储库同步?

In this StackOverflow question Copy/fork a git repo on github into same organization the asker wanted to create two separate disconnected repos one which was cloned from the other. 在这个StackOverflow问题中, 将github上的git repo复制/分叉到同一个组织中 ,提问者想要创建两个独立的连接的repos,其中一个是从另一个克隆的。

How do I create a forked project which multiple people will be able to see and work on from the 1 organization? 如何创建一个多人可以从1个组织查看和处理的分叉项目?


Further background 进一步背景

One of the repos in our organization is a template framework which we use to build dozens of other applications. 我们组织中的一个存储库是一个模板框架,我们用它来构建许多其他应用程序。 I am looking to solve the issue of when we add updates / patches to this template, the other repos are able to pull these changes. 我希望解决当我们向此模板添加更新/补丁时的问题,其他回购可以解决这些变化。

I don't want to fork to my individual account as that would be awful visibility for the organization in the future. 我不想分叉到我的个人帐户,因为这将是该组织未来的可见性。

I was facing a similar situation and came across this solution for cloning completed separated projects you listed. 我遇到了类似的情况,并且遇到了这个解决方案,用于克隆您列出的已完成的分离项目 With some simple editions, you can send branches across repositories and sync them manually thru pull requests. 使用一些简单版本,您可以跨存储库发送分支,并通过拉取请求手动同步它们。

I already had the cloned repository from the original, but if you don't have it, follow @larsks answer to clone and create a copy of the repo: 我已经拥有了原始克隆的存储库,但是如果你没有它,请按照@larsks的答案克隆并创建一个repo的副本:

$ git clone git@github.com:org/myrepo-original myrepo-new
$ cd myrepo-new
$ git remote set-url origin git@github.com:org/myrepo-new
$ git push origin master

After doing that, go back to the directory containing the original repository (the one where origin still points to git@github.com:org/myrepo-original used in the example) and add a remote pointing to the cloned using the command: 执行此操作后,返回包含原始存储库的目录( origin仍指向git@github.com:示例中使用的org / myrepo-original )并使用以下命令添加指向克隆的远程

$ git remote add cloned git@github.com:org/myrepo-new

Your original repo should look like this now: 您的原始仓库应该现在看起来像这样:

$ git remote -v

origin  git@github.com:org/myrepo-original (fetch)
origin  git@github.com:org/myrepo-original (push)
cloned  git@github.com:org/myrepo-new (fetch)
cloned  git@github.com:org/myrepo-new (push)

After this, you can push branches containing the stuff you want to the cloned repo and create pull requests to better visualize the contents and merges. 在此之后,您可以push包含所需内容的分支push送到cloned repo,并创建pull请求以更好地可视化内容并进行合并。

Let's say you want to update the master from the cloned repository with the master from original one: 比方说,你要更新的master从与克隆的仓库master从原来的一个:

$ cd myrepo-original
$ git checkout master
$ git checkout -b master-original
$ git push cloned master-original

And from myrepo-new on the GitHub interface create the PR using the base as master and compare as master-original . 从GitHub界面上的myrepo-new创建PR,使用base作为master并比较为master-original

Note : Although I think this would solve your problem, I would recommend based on the Further background you provided to research the possibility and turn your core/template repo on a submodule . 注意 :虽然我认为这可以解决您的问题,但我建议您根据您提供的进一步背景研究可能性并在子模块上转换核心/模板库。 In my opinion this makes it easier to update the core application between repos instead of "sending" branches cross repositories. 在我看来,这使得更容易更新repos之间的核心应用程序而不是“发送”分支交叉存储库。 =) =)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM