The Issue: when multiple users have access to the same working directory, permissions issues can occur in the meta-data if any git
operations are p
There are a number of ways to address this problem. Personally, I'd recommend the following in your existing repository:
# Create a group named "gitshare" that will share the repository.
sudo groupadd gitshare
# Add yourself and as many others as you want to the group.
sudo adduser "$LOGNAME" gitshare
# Everything else needs to run from the top level of your Git repository.
cd /path/to/repository
# Add group permissions for *new* modifications to repository.
git init --shared=group
# Fix permissions for existing repository objects.
chown -R :gitshare "$PWD"
chmod -R g+swX "$PWD"
Obviously, you need to make sure that the users have directory traversal permissions all the way to your repository (e.g. user-private directories may cause problems), and that all team members who need access belong to the repository's shared group. After this initial setup, though, it should "just work."
I just faced this issue and took me hours to find the solution when it was so simple. I tried almost everything I see on the other link provided by CodeGnome.
I'm using Centos 6.x and the solution was to change the umask on users... this require we do it with each account... We are only 2 working on the same directory. Not that much of a pain.
The solution that worked for me is this one, without having to change the server's configuration: http://www.avajava.com/tutorials/lessons/how-do-i-set-the-default-file-and-directory-permissions.html
If the .bashrc filoe do not exists in /home/user directory, like this was in my case, you only need to copy from the skeleton the file in /ect/skel and then you copy it your home (users) directory after adding at the end of the file:
umask 002
This gives the user a chmod 775 on the new folders created by others in the group. Of course, once this project will be completed, not anymore in a testing environment, we will set it back to chmod 755 (umask 022) by default. This not only give Git the permission to overwrite but also to write files uploaded on sFTP without having the permission denied issue. .