• Register
0 votes

Problem :

I want to push my code to the master branch of a repository but I am unable to do so, as it is protected.
Please find below the error message I am facing:

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

My repository is having only one branch and there are no contents in it so far.
It is the completely new repository with no contents and only default branch.
I have all the master permissions.
Unable to upload the image here because of some reason.Kindly suggest how can I push my code to master branch.

6 5 3
7,540 points

2 Answers

0 votes

Solution :

I have gone through your problem statement and I think your repository is with no contents in it so far

It means there is no master branch to protect currently, as the empty repository does not has one.

To do "Enable/disable branch protection", you must be Master or Owner of the GitLab project which you are.

Please make sure:

·     Your first push should be git push -u origin master;

·     Your remote origin references the right repo (git remote -v);

·     Your local ssh key should be the right one (ssh -T git@gitlab.ins.risk.regn.net);

·     You must be the member of the cmd group

9 7 4
38,600 points
0 votes


In GitLab few branches can be preserved. By default just Maintainer/Owner users can promise to protected branches . master branch is preserved by default - it forces developers to issue merge requests to be affirmed by project maintainers prior integrating them into main code.

You can turn on and off protection on chosen branches in Project Settings (where nicely relies on GitLab version - view instructions below).

On the similar settings page you can also approve developers to shock into the protected branches. With this setting on, protection will be limited to refusing operations claiming git push --force (rebase etc.)

Whereas GitLab 9.3

Go to project: "Settings" → "Repository" → "Expand" on "Protected branches"

Currently, you can choose who is approved to merge or push into chosen branches (for example: you can turn off pushes to master at all, forcing all alters to branch to be made through Merge Requests). Or you can click "Unprotect" to fully remove protection from branch.

Whereas GitLab 9.0

Likewise to GitLab 9.3, however no require to click "Expand" - everything is meanwhile expanded:

Go to project: "Settings" → "Repository" → scroll down to "Protected branches".

Pre GitLab 9.0

Project: "Settings" → "Protected branches" (in case you are at least 'Master' of given project).

Whereas  GitLab Enterprise Edition 9.3.0

1-Choose you "project"

2-Choose "Repository"

3-Choose "branches"

4-Choose "Project Settings"

5-In "Protected Branches" click to "expand"

6-and after click in "unprotect" button

That imply there is no master branch to protect yet, since the empty repo does not has one.

To "Enable/disable branch protection", you require to be Master or Owner of the GitLab project .

Ensure That:

  • Your first push is a git push -u origin master;

  • The remote root does reference the right repo (git remote -v);

  • Your local ssh key is the right one (ssh -T git@gitlab.ins.risk.regn.net);

  • You are a member of the cmd group.

10 6 4
31,120 points

Related questions

0 votes
1 answer 110 views
Problem: I am having only basic knowledge of git. Now I am trying to clone the project from a gitlab to my own local machine. I have already been granted rights as the developer on it and I have used the command as 'git clone’. But none of the ... “Remote: The project you were looking for could not be found.” Any help in fixing my git related error would be highly appreciated.
asked Sep 4 Raphael Pacheco 4.9k points
0 votes
1 answer 12 views
1 vote
1 answer 35 views
Problem: I have gained fundamental knowledge on Angular2. I am taking help of online tutorials to learn Angular2. I am trying to create the angular 2 App with the angular cli I have written below command in my cmd: npm install angular-cli -g After above command I am ... an error . I am unable to debug above error. I need Angular2 expert who can help me in fixing above Angular2 error for me.
asked Jun 5 Martin K 6.6k points