获取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命令即可回退回上次提交之前的状态

 

相关文章: