我在目标分支中使用命令时意外合并了拉取请求并将更改推送到远程存储库
git pull origin <source branch>
git push
此外,没有任何与此合并相关的提交。
恢复按钮在已关闭的拉取请求中不可见,我无法使用 git reset 命令,因为 PR 中有超过 50 次提交。
如何恢复 PR 的合并?
您可以将
git reset --hard ...
重置为 git pull...
之前的提交,并通过 git push --force
将结果推送到远程存储库。您可能必须在远程存储库端启用此功能。
使用 git-reflog 你可以找到之前状态的 SHA-1。
例如:
git status # check for any uncommitted status, get lost with following cli
git reset --hard a2de345 # reset to a state before the git pull
git push --force # forces git to overwrite the current history on the remote repository