今天在使用Git回退到之前某個版本的代碼時,進行push時出現如下錯誤:
! [remote rejected] master -> master (pre-receive hook declined)......

查閱相關資料發現,是由於當前用戶沒有push權限,就是[master]代碼默認是被保護的,所以進行push的時候會報錯;
解決方案:
登錄gitlab,選擇對應的項目,點擊[Setting],

選擇[Protected Branches];

解除[master]的保護即可;

push完代碼之后,再把[master]Protect起來即可;

