remote: GitLab: You are not allowed to push code to protected branches on this project

maddie picture maddie · Feb 6, 2017 · Viewed 80.5k times · Source

I am trying to push to master branch of a repo and I am failing to do so, since it is protected.
I tried to look into the project settings and do not see any option for protected branches. The only option I could see is members.

remote: GitLab: You are not allowed to push code to protected branches on this project.
To [email protected]:cmd/release.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:cmd/release.git'

My repo has only one branch, with no contents in it so far.
I do see protected branches options of my other Repos but not for this specific one.
It is a new repo with no contents and with only default branch.
I have the master permission.
Unfortunately I am not able to upload the image here somehow.

Please suggest how to push code to master branch.

Answer

山茶树和葡萄树 picture 山茶树和葡萄树 · Dec 17, 2018

12/17/2018

1. git push: "error: failed to push some refs to"

git push: error: failed to push some refs to

git push -f: "remote rejected"

git push -f: remote rejected

2. the branch is in a protected state and cannot be forced to operate.

Gitlab - Repository - Branches

Gitlab - Repository - Branches

3. temporarily remove branch protection.

Gitlab - Settings - Repository - Protected Branches - Unprotect

Gitlab - Settings - Repository - Protected Branches - Unprotect

4. try pushing again

git push -f

git push -f

5. may add protection