I have a problem when I push my codes to git while I have developer access in my project, but everything is okay when I have master access. Where is the problem come from? And how to fix it?
Error message:
error: You are not allowed to push code to protected branches on this project.
...
error: failed to push some refs to ...
A protected branch does three simple things: it prevents pushes from everybody except users with Maintainer permission. it prevents anyone from force pushing to the branch. it prevents anyone from deleting the branch.
there's no problem - everything works as expected.
In GitLab some branches can be protected. By default only Maintainer/Owner users can commit to protected branches (see permissions docs). master
branch is protected by default - it forces developers to issue merge requests to be validated by project maintainers before integrating them into main code.
You can turn on and off protection on selected branches in Project Settings (where exactly depends on GitLab version - see instructions below).
On the same settings page you can also allow developers to push into the protected branches. With this setting on, protection will be limited to rejecting operations requiring git push --force
(rebase etc.)
Go to project: "Settings" → "Repository" → "Expand" on "Protected branches"
I'm not really sure when this change was introduced, screenshots are from 10.3 version.
Now you can select who is allowed to merge or push into selected branches (for example: you can turn off pushes to master
at all, forcing all changes to branch to be made via Merge Requests). Or you can click "Unprotect" to completely remove protection from branch.
Similarly to GitLab 9.3, but no need to click "Expand" - everything is already expanded:
Go to project: "Settings" → "Repository" → scroll down to "Protected branches".
Project: "Settings" → "Protected branches" (if you are at least 'Master' of given project).
Then click on "Unprotect" or "Developers can push":
for the GitLab Enterprise Edition 9.3.0
By default, master branch is protected so unprotect :)
1-Select you "project"
2-Select "Repository"
3-Select "branches"
4-Select "Project Settings"
5-In "Protected Branches" click to "expand"
6-and after click in "unprotect" button
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With