git:how 将提交推送到另一个人的现有拉取请求?

git:how to push commits to the existing pull request from another person?

假设有一个中央仓库 A,我和我的同事已经分叉并添加了一个远程 upstream。我的一个同事发送了一个公关,我想在他的提交上做点什么。所以我直接$ git fetch upstream pull/ID/head:BRANCHNAME去取了。我对其进行了一些更改,并希望将其归档到现有的 pr 中。我将他的分叉回购添加为新遥控器并尝试 git push newRemote BRANCHNAME 但它说:

error: failed to push some refs to 'https://github.com/emeroad/pinpoint.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.

我不明白这是怎么回事。任何帮助将不胜感激!

他的 PR 分支可能在 PR 完成后发生了变化:

  • 你从上游获取
  • 他本可以在他的 PR 分支上添加新的提交
  • 你正在推送到 newRemote(他的 repo)

首先通过再次获取 PR 分支检查您是否看到任何更改。

OP 添加:

His pr hasn't changed but the master branch of upstream has been updated a lot so I rebased to the master on the pr branch

任何变基都意味着重新创建提交。从那里开始,任何推送(到任何远程)都将是强制推送。