How to fix permission denied for .git/ directory when performing git push?

Viewed 40789

I have set up a git repository on my server. Created a new user 'git'. My repos are located in /srv/git/example.git. I was able to git remote add origin git@domain/srv/git/example.git then I added and committed my changes.

However when I tried git push origin master it failed on:

fatal: unable to create temporary file: permission denied' and 'fatal: sha1 file write error: invalid argument'

On the server I ran:

sudo chown -R git:git /srv/git/`

This fixed my problem but I am wondering if this was the correct thing to do?

2 Answers
Related