在 github 中恢复合并的拉取请求

问题描述 投票:0回答:1

我在目标分支中使用命令时意外合并了拉取请求并将更改推送到远程存储库

git pull origin <source branch>
git push

现在 PR 说已经合并了

此外,没有任何与此合并相关的提交。

恢复按钮在已关闭的拉取请求中不可见,我无法使用 git reset 命令,因为 PR 中有超过 50 次提交。

如何恢复 PR 的合并?

git pull-request
1个回答
0
投票

您可以将

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
© www.soinside.com 2019 - 2024. All rights reserved.