Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git -- locking master branch for some users?

I would like to force other team-members to not work on the master-branch but on a development branch. we have a central git-repository where we push our work into. i would like to know if it's possible to block users from pushing changes to the master-branch but only allow certain users to do so.

I would like to have the following "workflow"

  • development is always only done with a development-branch
  • the release-manager is responsible for the master branch and only he is allowed to merge stuff from a development branch into the master and push it to the master-branch on the central repository to.

Is this possible and how can I achieve this?

like image 956
aurora Avatar asked Dec 10 '10 23:12

aurora


People also ask

How do I lock a specific branch in GitHub?

Lock the branch by selecting the ... icon next to the branch name and then selecting Lock from the menu. A lock icon will appear next to the branch name. Unlock a locked branch by selecting Unlock from the same menu.

How can we permit branches to certain users in GitHub?

You can only give push access to a protected branch, or give permission to create a matching branch, to users, teams, or installed GitHub Apps with write access to a repository. People and apps with admin permissions to a repository are always able to push to a protected branch or create a matching branch.


2 Answers

See man githooks: In the shared repo, you can create a $(git rev-parse --git-dir)/hooks/pre-receive or $(git rev-parse --git-dir)/hooks/update script that verifies what your users are trying to push to which refs. Git comes with a update-paranoid example hook enforcing per-ref ACLs.

like image 142
ephemient Avatar answered Sep 28 '22 12:09

ephemient


My low level approach would simply be to let the RM be the only one with SSH keys to push to the repository everyone else use as the master baseline. That way, nobody but the RM can push to master - yet everybody can work since they have their own local development branches and devs can share among themselves the branches they like.

The next step is to make a cooking pot tester for the things that will go into master soon. This pot is normally called next or dev. The idea is, that the more impact a branch has, the longer it cooks before a merge to master. This gives the RM full control over what branches should graduate and still gives everyone a heads-up.

like image 40
I GIVE CRAP ANSWERS Avatar answered Sep 28 '22 12:09

I GIVE CRAP ANSWERS