将提交推送到已打开拉取请求的另一个用户的分支

Pushing a commit to branch of another user who has opened a pull request

我在 github 上有一个存储库。我的存储库由另一个用户分叉。现在他提出了一个pull request。我想将我的一个提交推送到他的功能分支(他已经为此提出了 PR)。这可能吗。

这是我做的

git pull remote-ref-other-user feature-branch

完成此操作后,我可以提取他的提交。但是当我做一些更改时,添加另一个提交并尝试以这种方式推送它。

git push remote-ref-other-user feature-branch

我收到这个错误

error: src refspec feature-branch does not match any.
error: failed to push some refs to 'https://github.com/other-user/repo'

Is it possible to push a commit from my side to his branch. If yes then how can it be done.

假设你添加他的存储库,比如 "mysamplerepository",作为远程​​:

git remote add johnrepo https://github.com/john/mysamplerepository

您的分支名为 tweaks

如果您想将更改推送到他的存储库中名为 master 的分支,您可以这样做:

git push <remote-name> <source-ref>:<target-ref>

或者在这个例子中:

git push johnrepo refs/heads/tweaks:refs/heads/master

记住你还需要有写入权限(推送权限)才能推送到他的仓库。您可以在 Github's documentation.

上阅读更多相关信息

如果可行,将取决于写入权限:

  • 作为存储库所有者,您应该具有将提交添加到另一个用户的 PR 的写入权限(除非这在用户的 PR 中被明确关闭)
  • 如果您不是存储库所有者,您将无法向其他用户的 PR 添加额外的提交

为 GitHub 用户添加遥控器后,例如

git remote add <name of remote> git@github.com:<user>/<repo>.git

我用

git checkout -b <name of branch> <name of remote>/<name of branch> 

创建一个跟踪远程的本地分支。在我做出更改并提交后,我可以:

git push <name of remote> <name of branch>