Pushing remote git repositories

I followed the Using git to manage a web site howto. But it didn't work at first. Since I'm not very familiar with git "bare repositories", I started looking at that part. As it turns out, I should have started with the basics.

I was getting errors like this

tingo@kg-core2$ git push web
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 316 bytes | 316.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: fatal: this operation must be run in a work tree
To ssh://web2/home/tingo/website.git
   5f688e5..e969158  master -> master

Checking the basics, let me see if I can access that directory from the server

$ ls -la /usr/local/www/default/
ls: .: Permission denied
ls: ..: Permission denied
ls: index.html: Permission denied
total 0

aha - I can not! Checking further, I see that a crucial permission is missing on the directory:

$ ls -l /usr/local/www
total 8
drw-rw-r-x  2 root  wheel  512 Jun 22 18:14 default
lrwxr-xr-x  1 root  wheel   25 Jun 21 20:51 nginx -> /usr/local/www/nginx-dist
dr-xr-xr-x  2 root  wheel  512 Jun 21 20:51 nginx-dist

After fixing that in my ansible playbook and roles, and updating the server:

$ ls -la /usr/local/www/default/
total 12
drw-rwxr-x  2 root   wheel  512 Jun 22 19:04 .
drwxr-xr-x  4 root   wheel  512 Jun 21 22:10 ..
-rw-r--r--  1 tingo  wheel  188 Jun 22 19:04 index.html

and now pushing works:

tingo@kg-core2$ git push web
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 12 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 300 bytes | 300.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
To ssh://web2/home/tingo/website.git
   e969158..fefb6b3  master -> master

Not that complicated, but you got to check the basics first.