Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitlab and branch with specific access roles

Tags:

git

gitlab

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

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

e.g. master viewable by all, while develop branch viewable only by developers

is this possible, and how?

like image 691
tbo Avatar asked Dec 09 '14 12:12

tbo


1 Answers

The GitLab protection model is described in "Keeping your code protected".

It includes branch protection (as illustrated by this commit)

A protected branch does three simple things:

  • it prevents pushes from everybody except users with Master permission
  • it prevents anyone from force pushing to the branch
  • it prevents anyone from deleting the branch

You can make any branch a protected branch.
We make the master branch a protected branch by default, but you can turn that off.

Note that this is about read/write, not "visible/invisible": you can still clone the full repo and access read everything.


Sure enough, the OP tbo adds in the comments:

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

That is not how a Git repo works: If you have access to it, you can see all its content (through a clone).
If you have a content which must be invisible, then export it in its own git repo (which you can protect against access).
The first main repo can reference the second more private git repo as a submodule.

You can protect a branch against write (but not against read)

You can protect a repo against read (through teams).

like image 122
VonC Avatar answered Oct 15 '22 01:10

VonC