獲取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命令即可回退回上次提交之前的狀態