Thelambofgoat
Thelambofgoat

Reputation: 609

Git push to web site issues

I am trying to follow this guide http://toroid.org/ams/git-website-howto to make git push to website.

I made all steps up to pushing to the website, but then I got the error.

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

Seems that git didn't have permissions to write to the server. But as I granted permissions and I run

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

on my localhost to push data to website I get

Everything up-to-date

But how can it be up-to-date when the directory is just empty?

Upvotes: 0

Views: 812

Answers (1)

Math
Math

Reputation: 2446

So the answer (using the folder names from the guide you used) is that you had write access to the remote folder website.git where git was comparing the history, but not to /var/www/www.example.org where git was supposed to build the working tree.

So when you did git push web you updated website.git, then the post-receive hook was triggered and git tried to write in /var/www/www.example.org but permission was denied.

Once write permission has been added to /var/www/www.example.org, you can go to the website.git folder and run GIT_WORK_TREE=/var/www/www.example.org git checkout -f to create your working tree (and expose your website).

Upvotes: 5

Related Questions