title: How to fix permission denied for .git/ directory when performing git push?
body: <p>I have set up a git repository on my server. Created a new user 'git'. My repos are located in <code>/srv/git/example.git</code>. I was able to <code>git remote add origin git@domain/srv/git/example.git</code> then I added and committed my changes.</p>
  
  <p>However when I tried <code>git push origin master</code> it failed on:</p>
  
  <blockquote>
    <p>fatal: unable to create temporary file: permission denied' and 'fatal: sha1 file  write error: invalid argument'</p>
  </blockquote>
  
  <p>On the server I ran:</p>
  
  <pre><code>sudo chown -R git:git /srv/git/`
  </code></pre>
  
  <p>This fixed my problem but I am wondering if this was the correct thing to do?</p>