I've created a repository in /var/repo/myrepo.git using
git init --bare
and a post-receive hooks with inside:
#!/bin/sh
git --work-tree=/var/www/domain.com --git-dir=/var/repo/myrepo.git checkout -f
Then:
chmod +x post-receive
Now, push from local to remote works properly and I know that because I can see my local branch in
/var/repo/myrepo.git/refs/heads
But the problem is that the hooks do not work.
Then if I run from terminal:
git --work-tree=/var/www/domain.com --git-dir=/var/repo/myrepo.git checkout -f
all the file from the repo are copied to /var/www/domain.com
So why the hook do not work but the command inside do if executed from bash?
UPDATE_1
As suggested, inside /var/repo/myrepo.git/hooks/post-receive I'm using:
git --work-tree=/var/www/domain.com --git-dir=/var/repo/myrepo.git checkout -f >/tmp/mylogfile 2>/tmp/mylogfile
The file is executable becouse I can run it with:
./post-receive
This copy all the repo file inside my warking dir as expected, but the file "/tmp/mylogfile" is empty.