8

I am using Amazon EC2 to host a website which is deployed to the server via git. I used this tutorial previously on the same kind of EC2 Ubuntu Linux Server instance, and it has worked flawlessly. However, when I try and push to the server, I receive the following error trace:

Tutorial: http://toroid.org/ams/git-website-howto

Trace:

$ git push origin master Counting objects: 5, done. Writing objects: 100% (3/3), 250 bytes, done. Total 3 (delta 0), reused 0 (delta 0) remote: error: unable to create file index.html (Permission denied) To ssh://[email protected]/var/www/website.git 8068aac..04eae11 master -> master 

I only have one file inside the repository at the moment, which is index.html.

The error trace is showing that the permission is being denied to create the file. Please can you tell me where I am going wrong?

0

4 Answers 4

5

I believe if you run

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

this is coming from How to fix permission denied for .git/ directory when performing git push?

Sign up to request clarification or add additional context in comments.

1 Comment

+1 command worked for me, but the link is to an unrelated question
4

You probably didn't do this part of the tutorial:

First, the work tree (/var/www/www.example.org above) must be writable by the user who runs the hook (or the user needs sudo access to run git checkout -f, or something similar).

1 Comment

And what about Git on Windows? I face this permission denied error right now although I am an administrator and console which run, runs as administrator too. Its like a nightmare....
2

Your anti virus or some ot her program may be preventing that file from being written to your folder. If you observe carefully, you would realize that all other files have been created except the one for which the permission is denied. You may be having a protection software that is preventing creation of certain file types and no matter the user type you are logged-in, the file won't be created until you disable that software.

So check that your antivirus software isn't behind this for those running windows.

Comments

1

FYI, I had this error because I made a hook to update files in a separate website root directory. For example:

/var/www/project.git # (where we push updates) /var/www/project.com # (where the website exists) 

I forgot to add the group permission to the project.com directory. This made it all work, index.html appeared in the /var/www/project.com directory once I did the next commit/push!

Full code to make it work assuming you added your user to the "developers" group:

sudo chmod -R g+ws /var/www/project_name.git sudo chgrp -R developers /var/www/project_name.git sudo chmod -R g+ws /var/www/project_name sudo chgrp -R developers /var/www/project_name 

And the git setting for shared repository:

git config core.sharedRepository group 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.