我正在尝试按照本指南http://toroid.org/ams/git-website-howto将git推送到网站.
我已经迈出了推动网站的所有步骤,但后来我收到了错误.
user@user-PC:/var/www/html/laravel$ git push web +master:refs/heads/master
Counting objects: 826, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (750/750), done.
Writing objects: 100% (826/826), 6.05 MiB | 663.00 KiB/s, done.
Total 826 (delta 168), reused 0 (delta 0)
remote: error: unable to create file .gitattributes (Permission denied)
remote: error: unable to create file .gitignore (Permission denied)
remote: error: unable to create file CONTRIBUTING.md (Permission denied)
remote: fatal: cannot create directory at 'app': Permission denied
Run Code Online (Sandbox Code Playgroud)
似乎git没有写入服务器的权限.但是当我授予权限并且我运行时
user@user-PC:/var/www/html/laravel$ git push web
Run Code Online (Sandbox Code Playgroud)
在我的localhost上将数据推送到我得到的网站
Everything up-to-date
Run Code Online (Sandbox Code Playgroud)
但是当目录只是空的时候它怎么能是最新的呢?
所以答案(使用你使用的指南中的文件夹名称)就是你对远程文件夹有写入权限,website.git其中git正在比较历史记录,而不是/var/www/www.example.orggit应该构建工作树的位置.
所以,当你git push web更新了website.git,然后post-receive挂钩被触发并且git尝试写入/var/www/www.example.org但是权限被拒绝.
添加写入权限后/var/www/www.example.org,您可以转到该website.git文件夹并运行GIT_WORK_TREE=/var/www/www.example.org git checkout -f以创建工作树(并公开您的网站).