git -- locking master branch for some users?

aurora picture aurora · Dec 11, 2010 · Viewed 15.6k times · Source

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?

Answer

ephemient picture ephemient · Dec 11, 2010

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.