git 在我不拥有的 GitHub 项目上添加到其他人的拉取请求中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22237609/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:48:38  来源:igfitidea点击:

Adding to someone else’s pull request on a GitHub project that I do not own

gitgithub

提问by Dom Christie

Is it possible for me to add commits to someone else'spull request on a repository where I am not the owner?

我是否可以在我不是所有者的存储库上向其他人的拉取请求添加提交?

e.g.

例如

User A owns Project X.

用户 A 拥有项目 X。

User B forks Project X, creates a feature branch, makes some changes, and submits a pull request.

用户 B fork 项目 X,创建功能分支,进行一些更改,并提交拉取请求。

User C likes the pull request, but would like to make some modifications to it. (FWIW User C already has a fork of Project X, so is unable to easily fork User B's fork).

用户 C 喜欢拉取请求,但想对其进行一些修改。(FWIW 用户 C 已经有 Project X 的分叉,因此无法轻松分叉用户 B 的分叉)。

Can User C add commits to User B's PR?

用户 C 可以向用户 B 的 PR 添加提交吗?

采纳答案by Sam Brightman

You cannot add commits directly to User B's pull-request unless you have write access to User B's fork. You can, however, make local additions to the pull-request, by just fetching the pull-request branch into your own local repo (assuming the url for B's fork is public).

您不能直接向用户 B 的拉取请求添加提交,除非您对用户 B 的分叉具有写访问权限。但是,您可以对拉取请求进行本地添加,只需将拉取请求分支提取到您自己的本地存储库中(假设 B 的 fork 的 url 是公开的)。

I'm not sure if it's possible to do a pull-request into B's fork since your own fork is from A and not B, though.

不过,我不确定是否可以对 B 的叉进行拉取请求,因为您自己的叉来自 A 而不是 B。

回答by Sam Brightman

You can check out the branch and re-submit a modified PR (giving credit to the original, preferably).

您可以检查分支并重新提交修改后的 PR(最好将信用归功于原始)。

You can also issue a PR to the PR author:

您还可以向 PR 作者发出 PR:

git remote add userb https://github.com/userb/name.git
git fetch userb
git checkout featurebranch
[change and commit]
git push userc featurebranch

When you create a PR, GitHub lets you choose the base branch - so you can choose the fork and - if you want to - request changes to the PR.

当您创建 PR 时,GitHub 允许您选择基本分支 - 这样您就可以选择 fork 并且 - 如果您愿意的话 - 请求对 PR 进行更改。

回答by Naylor

User C can add directly to User B's pull request if User B has given permission, or possibly if user C is a committer on User A's repo.

如果用户 B 已授予权限,或者用户 C 可能是用户 A 存储库的提交者,则用户 C 可以直接添加到用户 B 的拉取请求中。

https://help.github.com/en/articles/committing-changes-to-a-pull-request-branch-created-from-a-fork

https://help.github.com/en/articles/committing-changes-to-a-pull-request-branch-created-from-a-fork

The github default permissions for users on a fork are copied from the original.

fork 上用户的 github 默认权限是从原始权限复制而来的。

If you do have permissions your command line to add would look like this:

如果您确实有权限,则要添加的命令行将如下所示:

git push https://github.com/[userb]/[projectx].git [userc_localbranch]

git push https://github.com/[userb]/[projectx].git [userc_localbranch]