gitlab回退到某次commit——本地+遠程


## 查看所有commits記錄
$ git log

## gitlab回退到某次commit
$ git reset --hard 3018a546427e1f865524b82b488d6a2721d00759
$ git reset 3018a546427e1f865524b82b488d6a2721d00759
注意:3018a546427e1f865524b82b488d6a2721d00759為commit id

## 強制重新提交到遠程
$ git push -f

git報錯You are not allowed to force push code to a protected branch on this project解決方案

當我們有時候回滾了代碼,想強制push到遠程倉庫的時候,
$ git push origin --force

會報如下錯誤:
You are not allowed to force push code to a protected branch on this project

如果用的是gitlab版本庫,這說明gitlab對倉庫啟用了保護,需要在倉庫中設置一下:

"Settings" -> "Repository" -> scroll down to "Protected branches". -> 找到項目,點擊"Unprotect"按鈕,使項目不受保護。

重新執行如下命令即可:
$ git push origin --force


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM