在GitHub上有一个公共回购的私人分支? [英] Having a private branch of a public repo on GitHub?

查看:209
本文介绍了在GitHub上有一个公共回购的私人分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GitHub仓库中有一个公共的PHP项目,它只包含一个分支(master)。

I have a public PHP project in a GitHub repo, which contains just one branch (master).

我想要一个独立的分支/分支对我来说(我已经支付了私人GitHub回购)。我希望能够将来自私人分支/分支的更改合并到公共回购中,反之亦然。

I want to have a separate branch/fork that is private for me (I have paid for private GitHub repos). I would like to be able to merge changes from the private branch/fork to the public repo, and vice versa.

考虑到这一点,以下是我的问题:

With that in mind, here are my questions:


  1. 我可以在公共回购协议中使用私人分支吗?

  2. 进入我自己的私人分支/分支?

  3. 如果以上两种都是可能的,哪种方法是最好的呢?如果没有,我该如何处理?

  1. Can I have a private branch on a public repo?
  2. Can I fork my own public repo into my own private branch/fork?
  3. If both of the above are possible, which is the best way forward? If neither, how should I proceed?


推荐答案


是否有可能在公共回购协议中使用私人分支?

在GitHub上,您的存储库是公开的或私人的;你不能有选择地私有化一个分支。

On GitHub, your repository is either public or private; you cannot selectively "privatize" just a branch.


我可以将自己的公共回购交易到我自己的私人分行/分支吗?

您可以将公共库回购克隆到本地计算机,根据需要分支,并且不要将您的私有分支上游(通过指定哪个分支推送到原始: git push origin master git push origin branch-i-想要成为公众:主人)。

You can clone your public repo to your local machine, branch as needed, and simply not push your "private" branches upstream (by specifying which branch to push to origin: git push origin master or git push origin branch-i-want-to-be-public:master).


我应该如何继续?

为了在公共和私人开发中充分利用GitHub,我建议在GitHub中分叉公共分支,将新分叉的设置更改为Private,然后将专用版本克隆到本地机器。当您准备好公开更改时,将所有内容都推送到GitHub上的私人分支,然后使用 拉取请求 以选择性地将分支复制到公共仓库。

In order to take advantage of GitHub for both your public and private development, I would suggest forking your public branch within GitHub, changing the settings of the new fork to "Private", and then cloning the private version down to your local machine. When you're ready to make changes public, push everything up to your private fork on GitHub and then use pull requests to selectively copy branches to the public repo.

要在GitHub上创建仓库,您必须升级(付费)帐户。如果您只是摇动免费账户,您仍然可以使用我建议的第一个流程 - — 克隆公共本地机器,分支,并将特定的公共分支推送到原始—而不需要私人回购。

To make a repository private on GitHub, you must have an upgraded (paid) account. If you're only rocking the free account, you can still use the first process I suggested — clone public to local machine, branch, and push specific "public" branches to origin — without needing a private repo.

如果您有付费的GitHub账户,或正在使用另一种提供公共和私人分支和拉取请求的服务(例如 BitBucket ),那么您可以使用上述任何一种方法来公开您的代码。

If you have a paid GitHub account, or are using another service that offers public and private forks and pull requests (such as BitBucket), then you can use either of the above approaches to make your code public.

这篇关于在GitHub上有一个公共回购的私人分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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