GitHub:如何将公共存储库的分支设为私有? [英] GitHub: How to make a fork of public repository private?

查看:87
本文介绍了GitHub:如何将公共存储库的分支设为私有?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何分叉公共存储库,但将我的分叉设为私有?我确实订阅了支持私有存储库的订阅.

How can I fork a public repository, but make my fork private? I do have the subscription to support private repositories.

推荐答案

答案是正确的,但没有提到如何在公共仓库和 fork 之间同步代码.

The answers are correct but don't mention how to sync code between the public repo and the fork.

以下是完整的工作流程(我们在开源 React Native 之前已完成此操作):

Here is the full workflow (we've done this before open sourcing React Native):

首先,复制其他人所说的 repo(详情此处):

First, duplicate the repo as others said (details here):

通过 Github UIprivate-repo)>.然后:

Create a new repo (let's call it private-repo) via the Github UI. Then:

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

<小时>

克隆私有存储库,以便您可以对其进行处理:


Clone the private repo so you can work on it:

git clone https://github.com/yourname/private-repo.git
cd private-repo
make some changes
git commit
git push origin master

<小时>

从公共存储库中提取新的热点:


To pull new hotness from the public repo:

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

太棒了,您的私人存储库现在包含来自公共存储库的最新代码以及您的更改.

Awesome, your private repo now has the latest code from the public repo plus your changes.

最后,创建一个 pull request 私有仓库 -> 公共仓库:

Finally, to create a pull request private repo -> public repo:

使用 GitHub UI 创建公共存储库的分支(公共存储库页面右上角的小Fork"按钮).然后:

Use the GitHub UI to create a fork of the public repo (the small "Fork" button at the top right of the public repo page). Then:

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 为 public-repo 创建拉取请求,如此处.

Now you can create a pull request via the Github UI for public-repo, as described here.

一旦项目所有者审核您的拉取请求,他们就可以合并它.

Once project owners review your pull request, they can merge it.

当然可以重复整个过程(只需省略添加遥控器的步骤).

Of course the whole process can be repeated (just leave out the steps where you add remotes).

这篇关于GitHub:如何将公共存储库的分支设为私有?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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