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