• 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

Please log in or register to answer this question.

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 436 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, 2020 Raphael Pacheco 4.9k points
0 votes
1 answer 38 views
1 vote
1 answer 29 views
Problem : I have recently started working on Continuous Integration. Currently I have the Continuous Integration which works properly with Gitlab. If I try to it deploy then it installs everything which is present in the requirements.txt file with the help of pip. ... .txt"         - "python manage.py migrate --noinput" Please help me in fixing the above error related to Continuous Integration.
asked May 13, 2020 Martin K 6.6k points
0 votes
1 answer 7 views
Can anyone help me?
asked Jan 4 TeamScript 9.2k points
1 vote
1 answer 40 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, 2020 Martin K 6.6k points
0 votes
2 answers 89 views
Problem : I want to compile a project in Eclipse using the m2eclipse. I set my JDK path in Eclipse as below: Windows-->preferences-->installed jres--> jdk1.7.xx path But this is showing me below error [ERROR] COMPILATION ERROR : [INFO] ------------------------------------------------------------- [ ... BUILD FAILURE [INFO] ------------------------------------------------------------------------
asked Feb 4, 2020 jwilliam 3.9k points
0 votes
1 answer 21 views
Problem: I have some knowledge on Gitlab. I have read few books and attended few sessions on Gitlab. Recently I have joined one new project on the Gitlab and I am working on it from the last couple of days!But to my surprise after a few days it all went suddenly ... it after struggling with it from more than two days. So now I need someone who knows Gitlab and can help me in fixing above error.
asked Jun 17, 2020 Raphael Pacheco 4.9k points