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

妖精的绣舞 提交于 2019-12-03 04:46:14

问题


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 git@github.com: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!


回答1:


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




回答2:


I was facing the same issue but it was not a permission issue.

When you are doing git clone it will create try to create replica of the respository structure.

When its trying to create the folder/directory with same name and path in your local os process is not allowing to do so and hence the error. There was "background" java process running in Task-manager which was accessing the resource of the directory(folder) and hence it was showing as permission denied for git operations. I have killed those process and that solved my problem. Cheers!!




回答3:


I was facing same issue then I read first few lines of this question and I realised that I was trying to run command at the root directory of my bash profile instead of CD/my work project folder. I switched back to my work folder and able to clone the project successfully




回答4:


You should logged in not as "root" user.

Or assign permission to your "current_user" to do this by using following command

sudo chown -R username.www-data /var/www

sudo chmod -R +rwx /var/www




回答5:


Change ownership and permissions folder

sudo chown -R username.www-data /var/www

sudo chmod -R +rwx /var/www



回答6:


use this for all user

sudo chown -R $(whoami):$(whoami) /var/..



回答7:


  1. Open your terminal.
  2. Run cd /
  3. Run sudo chown -R $(whoami):$(whoami) /var

Note: I tested it using ubuntu os




回答8:


Most common reason for this error is that you don't have permission to create file in the current directory. Ensure you are in the right directory. try this on mac system to list the directory

ls, then cd right_folder_name



来源:https://stackoverflow.com/questions/20276895/could-not-create-work-tree-dir-example-com-permission-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!