Git 推送到网站问题

Git push to web site issues

我正在尝试按照本指南 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

似乎 git 没有写入服务器的权限。但是当我授予权限并且我 运行

user@user-PC:/var/www/html/laravel$ git push web

在我的本地主机上将数据推送到我得到的网站

Everything up-to-date

但是目录是空的,怎么可能是最新的呢?

所以答案(使用 the guide you used 中的文件夹名称)是您对远程文件夹 website.git 具有写入权限,其中 git 正在比较历史记录,而不是 /var/www/www.example.org 其中 git 应该构建工作树。

所以当你 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 创建您的工作树(并公开您的网站).