Scenario
Local 端在 master branch 上執行 git push origin master 後出現以下 Error
remote: GitLab: You are not allowed to push code to protected branches on this project.
To http://xxx.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to ‘http://xxx.git’
Root Cause
關鍵字為
You are not allowed to push code to protected branches on this project
從 Google 得知為 GitLab 預設專案的 master branch 為 Protected,無法直接push commit 到 remote 的 master branch。
Solution
A. 透過GitLab的管理者權限將該專案的protected branch關閉。
GitLab->點擊該傳案->左方最下面的settings -> Repository ->點擊 Protected Branch的Expand -> 點擊 Unproject
B. 先git push 到其他branch上,再到GitLab將該branch merged到master(待測)