【发布时间】:2021-08-15 02:02:26
【问题描述】:
如何取消提交受保护分支上的最后一次合并?
git reset --hard HEAD~1
git push -f origin master
在注意到最后一次合并在生产环境中存在 UI 错误后,我执行了以下操作,但在本地环境中没有。
$ git push -f origin master
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: Cannot force-push to this protected branch
To https://github.com/Ivory/Web.git
! [remote rejected] master -> master (protected branch hook declined)
error: failed to push some refs to 'https://github.com/Ivory/Web.git'
但是,我无法执行强制推送,有没有办法取消提交更改?
【问题讨论】:
-
恢复提交(使用
git revert)可以工作,因为它会创建一个新的提交来恢复更改。但是,我不知道它如何处理合并提交。 -
要么暂时取消对分支的保护,要么推送一个提交以恢复合并所做的更改。
-
如何推送可以快速还原更改而无需手动执行的提交?
-
“快”是什么意思? “手动”是什么意思?
标签: git git-branch git-commit