title: File Permission issues with sharing a GIT Remote Repository
body: <p>I have a GIT repository that I manage for my office.  Because of company policy, we can't use external hosting providers such as GitHub and the like.  So, i'm left to do what I can with our local network.</p>
  
  <p>Everyone manages their own local repositories, but we also have a remote repository that our users push to (and are accessible to applications like Hudson and Fisheye) similar to how a central repo would work in subversion.  Each user has public keys setup so they can perform passwordless-authentication to the box hosting our remote repository as well.</p>
  
  <p>For our remote repository, I have them configured to be shared in "group" mode:</p>
  
  <pre><code>git config core.sharedRepository group
  </code></pre>
  
  <p>All of our users are also members of the git group, but that is not the primary group for many of the users.  It seems when git creates or updates any objects on "push," it uses the user's primary group.  Instead, I need it to use the common "git" group that each user is a member.  I've seen documentation on the web previously discussing setting the sticky bit, but it seemed to differ based on the source and didn't really address the issue of creating a common group (if i'm just making files arbitrarily write-able, I might as well make them 777).</p>
  
  <hr>
  
  <p><strong>Update:</strong></p>
  
  <p>Using Matthew Flaschen's <a href="https://stackoverflow.com/questions/5306768/file-permission-issues-with-sharing-a-git-remote-repository/5306825#5306825">answer below</a> </p>
  
  <pre><code>chgrp -R git repo.git 
  find repo.git -type d -exec chmod g+rws {} +
  </code></pre>
  
  <p>I was able to create a repository that everyone could push and pull from together.  I'll also look into gitolite, but my needs are pretty basic, and our environment allows for user and keys to be configured automatically, so it's use isn't as key.  However, I want to make sure that i'm dealing with this correct.</p>
  
  <p>My repository structure includes a top-level directory (remote-repos), and subdirectories for each of my repositories (app-1.git, app-2.git, library-1.git, etc).  I should be able to apply the chmod g+rws {} + to the top level directory (remote-repos) instead of each individual repo, correct?  The find command </p>
  
  <pre><code>find /opt/remote-repos -type d -exec ...
  </code></pre>
  
  <p>Finds all directories under the /opt/remote-repos location, and executes a command on them.  The command (chmod g+rws) ensures that the group can read and write these files, as well as sets the sticky bet so the specified group is always used when executing.  (I have no clue as to the use of the {} + portion, I'm assuming that's related to the find exec option).</p>
  
  <p>Anyway, just want to confirm that my understanding of this solution is correct.</p>
  
  <p><strong><em>More References:</em></strong></p>
  
  <ul>
  <li><a href="http://en.wikipedia.org/wiki/Chmod" rel="nofollow noreferrer">chmod</a> from Wikipedia</li>
  <li><a href="http://en.wikipedia.org/wiki/Setgid" rel="nofollow noreferrer">SetGID</a> (or SetUID) from Wikipedia </li>
  <li><a href="http://criticallog.thornet.net/2010/01/07/sharing-your-git-repository/" rel="nofollow noreferrer">Git SharedRepository</a> option discussion</li>
  </ul>