title: Why doesn't setting GIT_WORK_TREE work in a post-commit hook?
body: <p>I'm trying to use the following <code>post-commit</code> hook to deploy to a particular directory after each successful commit:</p>
  
  <pre><code>#!/bin/sh
  export GIT_WORK_TREE=/var/www/example/
  export GIT_DIR=/home/mark/test/.git/
  git checkout -f
  </code></pre>
  
  <p>However, after committing I get the following error:</p>
  
  <pre><code>$ git commit -m 'An example commit.'
  fatal: Unable to create '/var/www/example/.git/index.lock': No such file or directory
  [master 0938e48] An example commit.
  </code></pre>
  
  <p>... as if the <code>GIT_WORK_TREE</code> setting is being ignored.  Why does setting this environment variable appear to be not working?  I'm using git version 1.7.4.1.</p>