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.

We're having permission problem with Git on FreeBSD. The setup is fairly straight forward. We have a few different repos on the same server. For simplicity, let's say they reside in /git/repo1 and /git/repo2.

Each repo is owned by the user 'git' and a self-titled group (eg. repo1). The repo is configured with g+rwX access.

Every user who commits to the repository is also member of the group for the repo (eg. repo1).

The Git repositories all have 'sharedRepository = group' set.

So far so good, all users can check out the code from the repositories, and the first user can commit without any problem. However, when the next user tries to commit to the repositories, he will receive a permission error.

We've been banging our heads with this issue for some time now, and the only way we've managed to resolve it is by running the following script between commits (which is obviously very inconvenient):

find /git/repo1 -type d -exec chmod g+s {} \;
chmod -R g+rwX /git/repo1
chown -R git:repo1 /git/repo1/
cd /git/repo1
git gc

Anyone got a clue to where the problem lies?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Off the top of my head, possibly a umask issue?

Have you considered wrapping git with gitosis (http://vafer.org/blog/20080115011413)? I've found it a much more pleasant way of working with Git (no permissions headaches since the repo is owned by one OS user), and the permissions you can implement using gitosis are an attractive bonus.

share|improve this answer
1  
+1, umask by default is 022, you probably want 002 or similar. –  Chris S Mar 26 '10 at 20:22
    
The strange thing is that it does not seem to be a 'real' permission problem, as all files are writable to the entire group. –  vpetersson Mar 26 '10 at 23:36

When you create a new repository, set the group ownership of the folder, and give it a sticky bit:

chown git:repo1 /git/repo1

chmod g+ws /git/repo1

Also make sure your each user has the correct umask. You can set the default umask in /etc/login.conf. Look for the line under :default that looks like:

:umask=002:

Change it to:

:umask=022:

And run:

sudo cap_mkdb /etc/login.conf

share|improve this answer

Your Answer

 
discard

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.