简体   繁体   English

是否可以将公共 GitHub 存储库分叉到企业存储库中?

[英]Is it possible to fork a public GitHub repo into an enterprise repository?

There exist a public repo for Quick framework here .存在用于快速框架公共回购这里 I'd like to be able to fork this into a private enterprise GitHub repository.我希望能够将其分叉到私有企业 GitHub 存储库中。 Forking would allow all the branches to remain.分叉将允许所有分支保留。

the alternative would be to clone the repo and push up only a single branch to the enterprise but then I lose on not having all the branches from the source/original.另一种方法是克隆 repo 并仅将一个分支推送到企业,但随后我失去了没有来自源/原始分支的所有分支。

update: I ended up pushing all my branches into the enterprise git.更新:我最终将所有分支都推送到了企业 git 中。 if you just do a git push yourRemoteName myNewBranch then it will push the code into that branch on the enterprise git while creating that branch in enterprise GitHub.如果您只是执行 git push yourRemoteName myNewBranch ,那么它会将代码推送到企业 git 上的该分支,同时在企业 GitHub 中创建该分支。

It's not possible, because your GitHub Enterprise (GHE) installation is separate from the public one, so there's no way for the two systems to track each other's branch relationships.这是不可能的,因为您的 GitHub Enterprise (GHE) 安装与公共安装是分开的,因此两个系统无法跟踪彼此的分支关系。

The best you can do is exactly as you describe: Clone the repo, then push it to your GHE installation, and yes, you will then lose the branching relationships across repos.您能做的最好的事情就是按照您的描述:克隆存储库,然后将其推送到您的 GHE 安装中,是的,您将丢失存储库之间的分支关系。

The other option would be to keep a fork on the public GitHub (GH) repo--possibly keeping it in sync (manually, or with a cronjob) with your GHE repo.另一种选择是在公共 GitHub (GH) 存储库上保留一个分支——可能使其与您的 GHE 存储库保持同步(手动或使用 cronjob)。 Then you'll have two instances of your repo, and the public one would retain branch relationships with the original repo.然后你会有两个你的回购实例,公共的一个将保留与原始回购的分支关系。

Depending on why you need to put this on GHE, it may or may not work.根据您需要将其放在 GHE 上的原因,它可能会也可能不会起作用。 If you're making private contributions, it clearly won't work--as your private contributions would no longer be private.如果您进行私人捐款,它显然不会起作用——因为您的私人捐款将不再是私人的。 If you want it on GHE due to some corporate policy that all open source projects used internally are kept on the GHE, or something similar, then it would work, with the added administrative overhead of keeping the repo in sync two places.如果由于某些公司政策,即内部使用的所有开源项目都保存在 GHE 或类似的东西上,而希望在 GHE 上使用它,那么它会起作用,但会增加使 repo 在两个地方保持同步的管理开销。

While it isn't possible to fork from the public GitHub directly to your Enterprise installation, you can fork it on the public GitHub and then mirror that forked repository on your enterprise installation.虽然无法从公共 GitHub直接分叉到您的企业安装,但您可以在公共 GitHub 上分叉它,然后在您的企业安装上镜像该分叉存储库。

Steps脚步

  1. Create an empty repository on your enterprise GitHub:在您的企业 GitHub 上创建一个空存储库:
     curl https://github.yourenterprise.com/api/v3/user/repos \\ -u "yourUsername" \\ -d "{\\"name\\": \\"whatever-repository\\", \\"private\\": true }"
  2. Create a bare clone of your fork创建一个你的 fork 的裸克隆
    git clone --bare https://github.com/publicGitHubUser/forked-repository.git
  3. Change directories so you are inside the bare clones folder:更改目录,使您位于裸克隆文件夹中:
     cd ./whatever-repository.git/
  4. Push the repository with the --mirror flag to your enterprise GitHub将带有--mirror标志的存储库推送到您的企业 GitHub
     git push --mirror https://github.yourenterprise.com/enterpriseGitHubUser/forked-repository.git

More Information更多信息

https://help.github.com/articles/duplicating-a-repository/ https://help.github.com/articles/duplicating-a-repository/

If you use GitHub Enterprise then you automatically get access to GitHub Enterprise Cloud ie https://github.com/enterprises/mycompany , with the same licence count.如果您使用 GitHub Enterprise,那么您将自动获得对 GitHub Enterprise Cloud 的访问权限,即https://github.com/enterprises/mycompany ,具有相同的许可证计数。 This can be linked with SAML to your in-house Active Directory.这可以通过 SAML 链接到您的内部 Active Directory。 Then you can simply fork it in GitHub yet keep it within your company's control.然后,您可以简单地在 GitHub 中将其分叉,但仍将其保留在您公司的控制范围内。

Sadly you will still need to mirror clone it if you really need it on your in-house instance.遗憾的是,如果您真的需要在内部实例上使用它,您仍然需要对其进行镜像克隆。 However as you control both ends now, you should be able to use GitHub Actions (or Apps) to more intelligently keep them in sync.但是,当您现在控制两端时,您应该能够使用 GitHub 操作(或应用程序)更智能地保持它们同步。

@tasomaniac . @tasomaniac。 It looks like this 看起来像这样

在此处输入图片说明

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

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