title: Remove File from Bare Repository in Git
body: <p>A bit of back story, we maintain a submission system that allows students to submit source files to a git repository.  There are two options for doing this: for the more advanced students we simply let them use git.  For the beginner students, we have a web interface that allows them to upload files to their repository.</p>
  
  <p>The web interface itself is pretty basic, and right now only supports adding files. We would like to also give the students the ability to delete, however, we need to do the delete on the bare repository <strong>without cloning</strong>.  The clone operation is too expensive and requires too much space considering we have hundreds of repositories the submission system interacts with.</p>
  
  <p>We've been able to figure out how to add files directly to the tree without cloning.  We haven't been able to figure out the delete part in a bare repo.  I tried the following.</p>
  
  <pre><code>rm objects/70/574e5c0d5f1fb820f66fd3fd3a3c0c4ed398bb # blob id of file to be removed
  git write-tree # copying output
  echo "removing file" | git commit-tree &lt;copied id from previous command&gt; -p &lt;previous HEAD&gt; # copying ouput
  git update-ref refs/heads/master &lt;copied id from previous command&gt;
  </code></pre>
  
  <p>Technically this works, it just removes all the files from the repo which isn't exactly what we want.  I'm not exactly sure based on the internals of git how to remove a singular blob from the tree and update the bare repo, keeping the other files.</p>
  
  <p>Any ideas?</p>