我如何分叉一个公共存储库,但使我的分叉私有?我确实订阅了支持私有存储库。
当前回答
去https://github.com/new/import吧。
在“您的旧存储库的克隆URL”部分粘贴您想要的回购URL,并在“隐私”中选择“私有”。
其他回答
去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现在有一个导入选项,可以让你选择任何你想要的新导入的公共或私有存储库
推荐文章
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- 在GitHub上有一个公共回购的私人分支?
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- 只用GitHub动作在特定分支上运行作业
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 是否有一个链接到GitHub下载文件的最新版本的存储库?
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- git pull -rebase和git pull -ff-only之间的区别
- GitHub -致命:无法读取用户名https://github.com':没有这样的文件或目录
- 撤消git平分错误