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

I have a staging site that is a working directory of a git repository. How to set up git to let a developer pull out a branch or release without changing the group of the modified files?

An example. Let's say I have two developers, robin and david. They are both in git-users group, so initially they can both have write permissions on site.php.

-rw-rw-r--  1 robin git-users   46068 Nov 16 12:12 site.php
drwxrwxr-x  8 robin git-users    4096 Nov 16 14:11 .git

After robin-server1$ git pull origin master:

-rw-rw-r--  1 robin robin       46068 Nov 16 12:35 site.php
drwxrwxr-x  8 robin git-users    4096 Nov 16 14:11 .git

And david do not have write permissions on site.php, because the group changed from 'git-users' to 'robin'. From now on, david will get a permission denied, when he tries to pull to this repository.

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

This is best addressed with setting the permissions on all of the directories. If you set the the group 'sticky' bit, all files in the directory will maintain the group of the directory when members of the group modify them. So, to quickly set this on the staging site do the following:

chmod g+ws [directory]
find [directory] -type d -exec chmod g+ws {} \;
find [directory] -type f -exec chmod g+w {} \;

The first command sets the write and sticky bits for the group on the site top level directory. The second then finds all subdirectories of the top level folder and does the same. The third then makes sure the the group has write access to all of the files.

When you initially create the git repository, you can have it do the above automatically by using the --shared option:

git create --shared [directory]
share|improve this answer
add comment

Try with git submodules, that should be solution to what you need.

Or if you really don't want it, you can implement some scripts for this that will stash some files before pull and then pop them out, but this will also make you problems later with merging.

share|improve this answer
    
I don't really get it. How would a git submodule help me? –  mimrock Nov 20 '12 at 10:01
    
With git submodule different users can have control over different submodules, not clashing with each other, exactly what you asked for. Or, I had situation once with script which was stashing some files, run by some users, and then doing stash pop when it's run by other user, but the big issue here is merge conflicts, which you however have to resolve... –  Dejan Menges Nov 20 '12 at 22:08
    
I'm not sure I get you. Do you suggest to create a new, empty repository, and put the whole project into the root as one submodule because 'git submodule update' will not mess with the groups? –  mimrock Nov 21 '12 at 14:11
add comment

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.