Gitlab and branch with specific access roles

Is it possible to restrict access to certain branches in gitlab?

I want to have one repository with different branches and restrict access to specific users for certain branches

eg. a wizard visible to all when developing a branch visible only to developers

Is it possible, and how?

+5
source share
1 answer

The GitLab security model is described in the section "Saving Secure Code ."

It includes branch protection (as shown by this commit )

A protected branch does three simple things:

  • it prevents repulsion from everyone except users with wizard privileges.
  • he doesn’t allow anyone to force the branch
  • it does not allow anyone to delete a branch

You can make any branch a protected branch.
We make the master branch a secure default branch , but you can disable it.

Please note that this applies to reading / writing, not “visible / invisible”: you can still clone a complete repo and read access to everything.


Of course, OP tbo adds in the comments :

I need to find a way to limit visibility for a specific branch to specific users

This does not work Git repo: if you have access to it, you can see all its content (via a clone).
If you have content that should be invisible, then export it to your own Git repository (which you can protect against access).
The first main repo can refer to the second more closed Git repo as a submodule .

You can protect the branch from writing (but not against reading)

You can protect the repo from reading (via commands).

+3
source

Source: https://habr.com/ru/post/1208658/


All Articles