git fork回购到同一组织 [英] git fork repo to same organization

查看:62
本文介绍了git fork回购到同一组织的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将组织中的存储库分叉到相同组织中,以便可以定期将分叉与上游存储库同步?

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?

在此StackOverflow问题中复制/分叉git将github上的仓库回购到同一个组织中询问者想要创建两个单独的断开连接的仓库,一个从另一个仓库中克隆.

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.

我如何创建一个分叉的项目,多个人将可以在1个组织中看到该项目并进行工作?

How do I create a forked project which multiple people will be able to see and work on from the 1 organization?


更多背景

我们组织中的一个回购协议是一个模板框架,我们使用它来构建许多其他应用程序.我希望解决在我们向此模板添加更新/补丁时,其他存储库能够执行这些更改的问题.

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.

我已经从原始存储库中克隆了存储库,但是如果您没有它,请遵循@larsks answer 克隆并创建仓库的副本:

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:

$ 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

完成此操作后,返回包含原始存储库的目录(在该目录中,origin仍指向示例中使用的 git@github.com:org/myrepo-original ),然后使用命令添加远程指向克隆的对象:

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:

$ 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)

此后,您可以push包含要添加到cloned repo的内容的分支,并创建拉取请求以更好地可视化内容并合并.

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.

假设您要使用原始库中的master更新克隆存储库中的master:

Let's say you want to update the master from the cloned repository with the master from original one:

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

然后在GitHub界面上的myrepo-new中,使用基作为master创建PR,并与master-original进行比较.

And from myrepo-new on the GitHub interface create the PR using the base as master and compare as 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. =)

这篇关于git fork回购到同一组织的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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