Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

People also ask

How do I push permission to denied github?

This error means the key you are pushing with is attached to another repository as a deploy key, and does not have access to the repository you are trying to push to. To fix this, remove the deploy key from the repository, and add the key to your personal account instead.

How do I get permission for git?

Open Project settings>Repositories. To set the permissions for all Git repositories, choose Security. For example, here we choose (1) Project settings, (2) Repositories, and then (3) Security. Otherwise, to set permissions for a specific repository, choose (1) the repository and then choose (2) Security.


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?