title: How can one safely use a shared object database in git?
body: <p>I have read in several places that it's possible to share the <code>objects</code> directory between multiple git repositories, e.g. with symbolic links.  I would like to do this to share the object databases between several bare repositories in the same directory:</p>
  
  <pre><code>shared-objects-database/
  foo.git/
    objects -&gt; ../shared-objects-database
  bar.git/
    objects -&gt; ../shared-objects-database
  baz.git/
    objects -&gt; ../shared-objects-database
  </code></pre>
  
  <p>(I'm doing this because there are going to be lots of large blobs redundantly stored in each objects directory otherwise.)</p>
  
  <p>My concern about this is that when using these repositories, <code>git gc</code> will be called automatically and cause objects which are unreachable from one repository to be pruned, making the other repositories incomplete.  Is there any easy way of ensuring that this doesn't happen?  For example, is there a config option that would force <code>--no-prune</code> to be the default for <code>git gc</code>, and, if so, would that be sufficient to use this setup without risking losing data?</p>
  
  <p>At the moment, I've been using the <code>objects/info/alternates</code> mechanism to share objects between these repositories, but maintaining these pointers from each repository to all the others is a bit hacky.</p>
  
  <p>(My other alternative is to just to have a single bare repository, with all the branches of <code>foo.git</code>, <code>bar.git</code> and <code>baz.git</code> named <code>foo-master</code>, <code>foo-testing</code>, <code>bar-master</code>, etc.  However, that'd be a bit more work to manage, so if the symlinked objects directory can work safely, I'd rather do that.)</p>
  
  <p>You might guess that this is one of those Using Git For What It Was Not Intended use cases, but I hope the question is clear and valid nonetheless ;)</p>