1

My master branch in protected.

Just I want to make small(One line changes) commit on master.

I don't want to make a new branch and merge with master.

But i'm getting messages while push code on master:

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

Is it permission problem?

Can I make a commit to the protected branch?

1
  • 1
    Hi. Do you know what "protected branch" means? Commented Nov 22, 2018 at 7:44

3 Answers 3

1

You can commit locally, but, by default, no one (with exceptions, see link below) is allowed to push to a protected branch. You can change this default behavior in the settings; see gitlab documentation:

Since GitLab 8.11, you can define which roles are allowed to push to a protected branch via Settings->Repositories->Protected Branches: enter image description here

Alas, you should not carelessly commit and push to protected branches; they're mostly protected for a reason. Why not just create a merge request and lat your code be reviewed before it is merged?!

Sign up to request clarification or add additional context in comments.

Comments

0

In Gitlab only the project master can allow you to push in master, developpers have to issue merge request.

Go to Settings > Repository to change permissions or ask your project master to do it.

Comments

0

From the docs: https://docs.gitlab.com/ee/user/permissions.html

Only Maintainer or Owner have "Push to protected branches" permission.

To protect a branch, you need to have at least Maintainer/Owner permission level. Note that the master branch is protected by default.

Configuring protected branches To protect a branch, you need to have at least Maintainer permission level. Note that the master branch is protected by default.

  1. Navigate to your project’s Settings ➔ Repository
  2. Scroll to find the Protected branches section.
  3. From the Branch dropdown menu, select the branch you want to protect and click Protect. In the screenshot below, we chose the develop branch.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.