拉取请求时如何 return 提交

How to return to a commit when pull request

发出了拉取请求,然后无意中做了一些额外的提交,无法 return 到分支中的第一个提交。

我是做什么的:

git reset HEAD@{10}
git add .
git commit --amend --no-edit
git push origin areaSelection

错误:

To https://github.com/YaroshenkoYaroslav/WorldEdit.git
 ! [rejected]        areaSelection -> areaSelection (non-fast-forward)
error: failed to push some refs to 'https://github.com/YaroshenkoYaroslav/WorldEdit.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.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我该如何解决这个问题?

您有两个选择,这可能仅取决于您团队中的约定或您的 github 存储库的限制。

  1. 推送的内容不应该改变;所以只需在您的远程分支上创建一个新的提交并推送它。
  2. 你真的想重写你的分支的历史。这意味着之前推送的一些引用将消失(您删除的提交)。在那种情况下,你需要强制执行:git push --force-with-lease.