git--不小心推代码到master之后,怎么办?


获取commit id

git log

确定你要回滚到哪个版本

git reset --hard commit_id
git push origin master --force

成功!

 

报错:remote: GitLab: You are not allowed to force push code to a protected branch

如果用的是gitlab版本库,这说明gitlab对仓库启用了保护,需要在仓库中设置一下:

"Settings" -> "Repository" -> scroll down to "Protected branches".

在gitlab重新设置之后,重新执行push命令即可回退回上次提交之前的状态

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM