git undo commit 在 protected 分支上?

标签 git commit git-commit

有没有办法撤消 protected 分支上的提交?

我的意思是,如果你推送了一个错误的提交,在一个不 protected 分支上,你可以撤消它,将 HEAD 重置为最后一个期望的提交,或者恢复错误的提交并强制推送。但是 protected 分支不允许强制推送。这种情况下有什么办法可以解决?

编辑:指定的(正确的)提交不是 merge 。

最佳答案

reverting the wrong commit

git revert SHA-1    
git commit ....
git push origin <branch>

如果您的分支受到保护并且您无法执行 git push -f ... 您可以简单地执行 revert

git revert
Revert some existing commits

关于git undo commit 在 protected 分支上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35958394/

相关文章:

git - 无法使用 SSH 将 IntelliJ-IDEA 连接到 GitLab

git - Xcode 9 提交 : Couldn't communicate with helper application

git - 如何在 Github 上更改项目的许可证?

git - 如何提交没有更改和新消息?

git commit 到所有分支

git - 为什么将 git 存储库复制到另一个目录后我修改了文件?

git - 在 Vim 中限制或改变特定行的颜色

git - 如何在 github 上直观地查看两个 git 提交之间的差异

git - 在开源项目的分支上开发 2 个功能

git - 如何只获取一个分支的提交历史?