6

I'm an owner of a GitLab repository, but when I try to push from a local machine, using an access token that I generated on GitLab's page, it fails.

Writing objects: 100% (980/980), 8.49 MiB | 3.22 MiB/s, done. Total 980 (delta 537), reused 0 (delta 0) remote: Resolving deltas: 100% (537/537), done. remote: GitLab: You are not allowed to force push code to a protected branch on this project. To https://myurl.git ! [remote rejected] master -> master (pre-receive hook declined)

In this SO post, it says that an 'owner'(and 'maintainer') can push

how can I solve this

1

1 Answer 1

7

The branch you try to force push to is protected. This is a setting, you can change in your project in Settings > Repository > protected branches.

This feature gives you as a maintainer and owner additional flexibility in controlling branch access and although you are allowed to push. you are not allowed to force push, as soon as a branch is protected.

This means, you need to deactivate branch protection for the branch you try to push too.

From the GitLab documentation:

By default, a protected branch does these things:

  • It prevents its creation, if not already created, from everybody except users with Maintainer permission.
  • It prevents pushes from everybody except users with Allowed permission.
  • It prevents anyone from force pushing to the branch.
  • It prevents anyone from deleting the branch.

enter image description here

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

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.