• Register
0 votes
260 views

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

Solution:

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

1 vote
1 answer 7 views
7 views
Problem: Why I got the error : the activity must be exported or contain an intent-filter. you are not allowed to push code to protected branches on this project.
asked Mar 7 MUHAMMAD MUNEEB 80k points
0 votes
1 answer 1.2K views
1.2K 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 9 views
9 views
Problem: How to fix this error: Whoops, gitlab is taking too much time to respond. I don't know how to resolve this problem.
asked Mar 9 ummesalma 21.9k points
0 votes
1 answer 1 view
1 view
Problem: I have accepted and merged a pull request on GitHub, and now I cannot pull my commits anymore. The message is: error: failed to push some refs to '*Emails are not allowed*:FranckFreiburger/vue-resize-sensor.git'
asked Mar 31 ummesalma 21.9k points
0 votes
1 answer 2 views
2 views
Problem: I am prompted to enter my GitLab username and password. After the password is entered I get: remote: HTTP Basic: Access denied fatal: Authentication failed for
asked Mar 30 ummesalma 21.9k points
0 votes
1 answer 20 views
20 views
Problem: Auto packing the repository in background for optimum performance.
asked Feb 13 Shovo210 13.2k points
0 votes
1 answer 2 views
2 views
Problem: Please assist me in resolving this issue: you are not allowed to access this file. check index_dev.php for more information.
asked Apr 1 rakib1 50.4k points
1 vote
1 answer 3 views
3 views
Problem: Please help me to solve it out : sorry you are not allowed to access this page. wordpress
asked Mar 18 MUHAMMAD MUNEEB 80k points
1 vote
1 answer 6 views
6 views
Problem: Please help me. How can I solve it? sorry you are not allowed to access this page. wordpress admin
asked Mar 18 MUHAMMAD MUNEEB 80k points
1 vote
1 answer 3 views
3 views
Problem: Please help me to solve it out : sorry, you are not allowed to access this page.
asked Mar 18 MUHAMMAD MUNEEB 80k points