git 是否可以将公共 GitHub 存储库分叉到企业存储库中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29952033/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to fork a public GitHub repo into an enterprise repository?
提问by j2emanue
There exist a public repo for Quick framework here. I'd like to be able to fork this into a private enterprise GitHub repository. Forking would allow all the branches to remain.
存在用于快速框架公共回购这里。我希望能够将其分叉到私有企业 GitHub 存储库中。分叉将允许所有分支保留。
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. 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 中。如果您只是执行 git push yourRemoteName myNewBranch ,那么它会将代码推送到企业 git 上的该分支,同时在企业 GitHub 中创建该分支。
采纳答案by Flimzy
It's not possible, because your Enterprise GitHub installation is separate from the public one, so there's no way for the two systems to track each other's branch relationships.
这是不可能的,因为您的 Enterprise GitHub 安装与公共安装是分开的,因此两个系统无法跟踪彼此的分支关系。
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 GH repo--possibly keeping it in sync (manually, or with a cronjob) with your GHE repo. Then you'll have two instances of your repo, and the public one would retain branch relationships with the original repo.
另一种选择是在公共 GH 存储库上保留一个分支——可能使其与您的 GHE 存储库保持同步(手动或使用 cronjob)。然后你将有两个你的回购实例,公共的一个将保留与原始回购的分支关系。
Depending on why you need to put this on GHE, it may or may not work. 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 或类似的东西上,而希望在 GHE 上使用它,那么它会起作用,但会增加使 repo 在两个地方保持同步的管理开销。
回答by Pytry
While it isn't possible to fork from the public GitHub directlyto your Enterprise installation, you can fork it on the public GitHub and then mirror that forked repository on your enterprise installation.
虽然无法从公共 GitHub直接分叉到您的企业安装,但您可以在公共 GitHub 上分叉它,然后在您的企业安装上镜像该分叉的存储库。
Steps
脚步
- Create an empty repository on your enterprise GitHub:
curl https://github.yourenterprise.com/api/v3/user/repos \ -u "yourUsername" \ -d "{\"name\": \"whatever-repository\", \"private\": true }"
- Create a bare clone of your fork
git clone --bare https://github.com/publicGitHubUser/forked-repository.git
- Change directories so you are inside the bare clones folder:
cd ./whatever-repository.git/
- Push the repository with the
--mirror
flag to your enterprise GitHubgit push --mirror https://github.yourenterprise.com/enterpriseGitHubUser/forked-repository.git
- 在您的企业 GitHub 上创建一个空存储库:
curl https://github.yourenterprise.com/api/v3/user/repos \ -u "yourUsername" \ -d "{\"name\": \"whatever-repository\", \"private\": true }"
- 创建一个你的 fork 的裸克隆
git clone --bare https://github.com/publicGitHubUser/forked-repository.git
- 更改目录,使您位于裸克隆文件夹中:
cd ./whatever-repository.git/
- 将带有
--mirror
标志的存储库推送到您的企业 GitHubgit push --mirror https://github.yourenterprise.com/enterpriseGitHubUser/forked-repository.git
More Information
更多信息