Could not create work tree dir 'example.com'.: Permission denied

David Ingledow picture David Ingledow · Nov 29, 2013 · Viewed 110.2k times · Source

I have got a virtual private server with nginx Virtual Hosts setup (Server Blocks).

I've installed Git and got my ssh keys authenticated with GitHub.

I have my website running in

 ~/var/www/example.com/public_html/

I tried to run:

git clone [email protected]:example/example.co.uk.git

to pull my files on GitHub to the /public_html/ directory but I get the error:

fatal: could not create work tree dir 'example.com'.: Permission denied

I've followed this tutorial including the same issue he has mentioned on the page, but it still won't work: http://machiine.com/2013/pulling-a-git-repo-from-github-to-your-ubuntu-server/

I'm completely new to this, so your help would be much appreciated!

Answer

Wil picture Wil · Apr 18, 2014

I think you don't have your permissions set up correctly for /var/www Change the ownership of the folder.

sudo chown -R **yourusername** /var/www