简体   繁体   English

git在受保护的分支上撤消提交?

[英]git undo commit on protected branch?

Is there a way to undo commits on a protected branch? 有没有办法撤消受保护分支上的提交?

I mean, If you pushed an wrong commit, on a non protected branch you can undo it reseting the HEAD to the last desired commit or reverting the wrong commits and forcing the push then. 我的意思是,如果你推送了一个错误的提交,在一个非受保护的分支上,你可以撤消它将HEAD重置为最后一个所需的提交,或者恢复错误的提交然后强制推送。 But protected branches does not allow force pushing. 但受保护的分支不允许推力。 What's the way to fix it on this case? 在这种情况下修复它的方法是什么?

Edit: The specified (rigtht) commit is not a merge. 编辑:指定的(rigtht)提交不是合并。

reverting the wrong commit 恢复错误的提交

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

If your branch is protected and you can't perform a git push -f ... the you you can simply execute a revert . 如果您的分支受到保护而您无法执行git push -f ...那么您只需执行revert

git revert
Revert some existing commits 还原一些现有提交

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM