Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

This is my first time setting up a git server, so I don't really know what I am doing yet. Anyways, I have a git server setup with a user, What I want is to have multiple developers that can create their own branches and push the branches to origin, but I don't want them to push anything to master; an admin will merge after a code review. Is that possible?

share|improve this question

3 Answers 3

up vote 3 down vote accepted

Gitolite can do this for you. There's no way for you to set this up with the default git setup.

share|improve this answer

If you don't want to use Gitolite, add this to your update hook:

[ "$1" != refs/heads/master ] || {
    echo "ERROR:  you are not allowed to update master" >&2
    exit 1
share|improve this answer

Extending the answer of Richard a bit: Use the following snippet as your "hooks/update" and pushing to master will only be allowed to the user with the name "git-repo-admin":

if [ $USER != "git-repo-admin" ];
  if [ "$1" == refs/heads/master ];
    echo "Manual pushing to this repo is restricted"
    exit 1
share|improve this answer
This won't work where my origin is set to git@someserver.com:/git/main.git, as $USER will always be "git". –  RCross Oct 15 '14 at 15:57
USER_EMAIL=$(git log -1 --format=format:%ae HEAD) USER_NAME=$(git log -1 --format=format:%an HEAD) answers.atlassian.com/questions/58346/… –  Krekkon Nov 25 '14 at 11:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.