我如何分叉一个公共存储库,但使我的分叉私有?我确实订阅了支持私有存储库。
当前回答
答案是正确的,但没有提到如何在公共回购和分叉之间同步代码。
以下是完整的工作流程(我们在开源React Native之前就已经这样做了):
首先,复制其他人所说的回购(详情在这里):
通过Github UI创建一个新的回购(让我们称之为私有回购)。然后:
git clone --bare https://github.com/exampleuser/public-repo.git
cd public-repo.git
git push --mirror https://github.com/yourname/private-repo.git
cd ..
rm -rf public-repo.git
克隆私有回购,这样你就可以对它进行操作:
git clone https://github.com/yourname/private-repo.git
cd private-repo
make some changes
git commit
git push origin master
从公共回购中获取新的热点:
cd private-repo
git remote add public https://github.com/exampleuser/public-repo.git
git pull public master # Creates a merge commit
git push origin master
太棒了,您的私人回购现在有来自公共回购的最新代码加上您的更改。
最后,创建一个pull request private repo -> public repo:
使用GitHub UI创建公共回购的fork(公共回购页面右上方的小“fork”按钮)。然后:
git clone https://github.com/yourname/the-fork.git
cd the-fork
git remote add private_repo_yourname https://github.com/yourname/private-repo.git
git checkout -b pull_request_yourname
git pull private_repo_yourname master
git push origin pull_request_yourname
现在,您可以通过Github UI为公共回购创建一个拉请求,如下所述。
一旦项目所有者审查了您的pull请求,他们就可以合并它。
当然,整个过程可以重复(只需省略添加遥控器的步骤)。
其他回答
GitHub现在有一个导入选项,可以让你选择任何你想要的新导入的公共或私有存储库
去https://github.com/new/import吧。
在“您的旧存储库的克隆URL”部分粘贴您想要的回购URL,并在“隐私”中选择“私有”。
答案是正确的,但没有提到如何在公共回购和分叉之间同步代码。
以下是完整的工作流程(我们在开源React Native之前就已经这样做了):
首先,复制其他人所说的回购(详情在这里):
通过Github UI创建一个新的回购(让我们称之为私有回购)。然后:
git clone --bare https://github.com/exampleuser/public-repo.git
cd public-repo.git
git push --mirror https://github.com/yourname/private-repo.git
cd ..
rm -rf public-repo.git
克隆私有回购,这样你就可以对它进行操作:
git clone https://github.com/yourname/private-repo.git
cd private-repo
make some changes
git commit
git push origin master
从公共回购中获取新的热点:
cd private-repo
git remote add public https://github.com/exampleuser/public-repo.git
git pull public master # Creates a merge commit
git push origin master
太棒了,您的私人回购现在有来自公共回购的最新代码加上您的更改。
最后,创建一个pull request private repo -> public repo:
使用GitHub UI创建公共回购的fork(公共回购页面右上方的小“fork”按钮)。然后:
git clone https://github.com/yourname/the-fork.git
cd the-fork
git remote add private_repo_yourname https://github.com/yourname/private-repo.git
git checkout -b pull_request_yourname
git pull private_repo_yourname master
git push origin pull_request_yourname
现在,您可以通过Github UI为公共回购创建一个拉请求,如下所述。
一旦项目所有者审查了您的pull请求,他们就可以合并它。
当然,整个过程可以重复(只需省略添加遥控器的步骤)。
现在多了一个选择(2015年1月)
创建一个新的私有回购 在空的回购屏幕上有一个“导入”选项/按钮 点击它,并把现有的github回购url 没有github选项提到,但它与github回购工作太。 完成
目前的答案有点过时了,所以,为了清楚起见:
简单的回答是:
做一个公共回购的纯克隆。 创建一个新的私有的。 做一个镜像推送到新的私有。
这在GitHub上有文档:复制一个存储库
推荐文章
- 如何运行一个github-actions步骤,即使前一步失败,同时仍然失败的工作
- 当我试图推到原点时,为什么Git告诉我“没有这样的远程‘原点’”?
- 在GitHub repo上显示Jenkins构建的当前状态
- 如何从远程分支中挑选?
- 如何查看一个分支中的哪些提交不在另一个分支中?
- 如何取消在github上的拉请求?
- HEAD和master的区别
- GIT克隆在windows中跨本地文件系统回购
- RPC失败;卷度传输已关闭,剩余未完成的读取数据
- 我应该在.gitignore文件中添加Django迁移文件吗?
- 错误:您对以下文件的本地更改将被签出覆盖
- Git rebase—即使所有合并冲突都已解决,仍然会继续报错
- 在Git中,我如何知道我的当前版本是什么?
- 跟踪所有远程git分支作为本地分支
- 自定义SSH端口上的Git