title: Git checkout in post-receive hook: "Not a git repository '.'"
body: <p>I have a non-bare repository at my server (dirs /home/andrew/web and /home/andrew/web/.git), set receive.denyCurrentBranch to ignore and created post-receive hook:</p>
  
  <pre><code>#!/bin/sh
  GIT_WORK_TREE=/home/andrew/web git checkout -f
  </code></pre>
  
  <p>When I run sh .git/hooks/post-receive, everything works fine. But when I push from my PC I get this error:</p>
  
  <pre><code>remote: fatal: Not a git repository: '.'
  </code></pre>
  
  <p>Is there a way how can I solve this issue? And eventually without having to switch bare repo?</p>
  
  <p>Thank you</p>
  
  <p>EDIT: Here's my new post-receive hook. Why it is like this has been described in the accepted answer.</p>
  
  <pre><code>echo "\nChecking out $PWD"
  GIT_DIR=/home/andrew/web/.git
  GIT_WORK_TREE=/home/andrew/web git checkout -f
  </code></pre>