GitHub 可以从私有仓库拉取请求到公共仓库吗?
我分叉了一个公共存储库并将新的存储库设为私有。
我在我的私人存储库上添加了一个新的远程分支,并提交了一些修复。
现在,我想从我的私人存储库中的分支向我分叉的公共存储库创建拉取请求。
我在我的私人存储库中选择分支并单击“拉取请求”。
我点击“更改提交”。
我无法更改组织/存储库所有者。我只看到我的组织,但看不到公共仓库的组织。我只能针对我的私人存储库的主分支创建拉取请求,但这不是我想要的。
是否无法在私人仓库中修复公共仓库的某些内容并随后创建拉取请求?
I forked a public repo and made the new repo private.
I added a new remote branch on my private repo with some fixes committed.
Now, I want to create a pull request from the branch in my private repo towards the public repo I forked from.
I select the branch in my private repo and click "Pull request".
I click on "Change commits".
I can't change the organisation/repo owner. I only see my organisation, but not the one of the public repo. I could only create a pull request against master branch of my private repo, but that's not what I want.
Is it not possible to fix something of a public repo in a private one and create a pull request afterwards?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一种解决方案是将原始公共存储库分叉到您自己的 GitHub 上公共存储库中。
然后 将您分叉的公共存储库复制到私有存储库中一个。
然后,您将两者克隆到本地工作站上,并且:
One solution would be to fork the original public repo into your own public repo on GitHub.
Then duplicate your forked public repo into a private one.
You then clone both on your local workstation, and:
2021 更新
@VonC 的答案在概念上是正确的,并且仍然是 GitHub 支持的答案。九年后,@Sebi终于得到了他想要的答案 - 我消除了他评论的 VonC 答案第二个项目符号中出现的“间接”。
对于我的用例,我需要对公共存储库进行公共和私有更改。公共提交一旦准备好就可以定期推送。私人更改必须保留在我的私人存储库中,直到我完成我的博士研究。那时,我需要所有私人更改通过拉取请求从我的公共分叉流到原始公共存储库。
大部分工作是正确设置。我在此答案中提供了详细步骤。以下步骤仅在 eclipse GUI(v2020-12;EGit 5.11)中完成,但可以轻松转换为命令行操作。我使用的存储库如下:
eclipse/org.aspectj
是原始公共存储库;用于获取cb4/org.aspectj
的上游
远程cb4/remPrivAJ
的origin
远程private
远程I:\local
是我工作站上的本地存储库对于 github 身份验证,我使用 ssh 和 ed25519 ssh键(这个问题的操作方法) 所以我的连接 URI 如下所示:
ssh://[电子邮件受保护]/<用户>/<存储库>
。表示法:
->
是鼠标单击或选择;右->
和double->
分别是右键单击和双击。我将公共更改与私人更改分开,将每个更改放在单独的分支中:
pub
用于公共更改;priv
用于私人更改。我对 git 相当陌生,所以可能有更好的方法来做到这一点。Branches
然后打开Local
(每个旁边都有-> v
)右键->大师->创建分支->选择->私有/主控->确定
输入 priv 作为分支名称:->配置上游的推和拉 ->拉取时:合并->完成
右键->大师->创建分支
输入 pub 作为分支名称:->完成
private/master
、我的公共分叉orign/master
和原始公共存储库upstream/ 中提交编号掌握所有匹配

Git Staging
选项卡上查看有关这些更改的详细信息->;提交并推送 ->预览->推->关闭
right->;私人 ->推送分支->远程:下拉 v -> origin: URI
(我的是 origin:ssh://[email protected] /cb4/org.aspectj)双-> master
在 Branch: 文本框中输入priv
,然后输入double->; priv [分支] ->预览->推->关闭
其他特性和功能
right->;酒吧->推送分支->预览->推->关闭
right->;上游->获取
right->;起源->推送
右->;私人 ->推送
2021 Update
@VonC's answer is conceptually correct and still the one supported by GitHub. After nine years, @Sebi finally gets the answer he wanted -- I eliminated the "indirection" he commented on that occurs in the second bullet of VonC's answer.
For my use case, I need to make both public and private changes to a public repo. Public commits can be pushed periodically as soon as they are ready. Private changes must remain in my private repo until I complete my PhD research. At that time, I'll need all private changes to flow from my public fork to the original public repo via pull requests.
The bulk of the work is getting things set up correctly. I provided detailed steps in this SO answer. The following steps are done exclusively in the eclipse GUI (v2020-12; EGit 5.11), but can easily be translated to command line operations. The repositories I used are these:
eclipse/org.aspectj
is the original public repo; theupstream
remote for fetchingcb4/org.aspectj
is my fork; theorigin
remote for pushingcb4/remPrivAJ
is my remote private repo; theprivate
remote for pushing and pullingI:\local
is the local repo on my workstationFor github authentication, I used ssh with an ed25519 ssh key (how-to in this SO question) so my connection URIs look like this:
ssh://[email protected]/<user>/<repo>
.Notation:
->
is a mouse click or selection;right->
anddouble->
are right-click and double-click, respectively.I separated public from private changes by putting each in separate branches:
pub
for public changes;priv
for private changes. I'm fairly new to git, so there may be a better way to do this.Branches
then openLocal
(-> v
beside each)right-> master -> Create Branch -> Select -> private/master -> Ok
enter priv forBranch name: -> Configure upstream for push and pull -> When pulling: Merge -> Finish
right-> master -> Create Branch
enter pub forBranch name: -> Finish
private/master
, my public forkorign/master
, and the original public repoupstream/master
all matchGit Staging
tab in the Git Perspective-> Commit and Push -> Preview -> Push -> Close
right-> priv -> Push Branch -> Remote: dropdown v -> origin: URI
(mine is origin:ssh://[email protected]/cb4/org.aspectj)double-> master
in the Branch: text box and typepriv
thendouble-> priv [branch] -> Preview -> Push -> Close
Compare & pull request
and Voila! (click image to zoom).Additional Features and Functions
right-> pub -> Push Branch -> Preview -> Push -> Close
right-> upstream -> Fetch
right-> origin -> Push
right-> private -> Push
我怀疑这是 Github 的初衷,但实际上您可以通过一些简单的 DOM 操作从私有存储库向公共存储库发出拉取请求:
一些注意事项:
I doubt it's intended by Github but you can actually make a pull request from a private to a public repo with a bit of simple DOM manipulation:
Some caveats: