I recently have started using Git in my daily workflow and I really love working with it.
I have a bare online repo (git init --bare --shared) sitting on my VPS under a folder called website.git and push pull changes to it from local whenever I need to, which works absolutely fine. Now, when I save data on my local repo, I push the changes online, but then I have to manually move the files into the public_html folder too, which as you can imagine, is a real pain.
I have tried using git hooks as described in http://toroid.org/ams/git-website-howto, but it's the permissions that are not working for me.
Both the public_html and website.git folders are owned by www-data:developers, but when the post-receive hook kicks in, it can't unlink the old files, and any new files are automatically owned by jack:jack which is the user I SSH into the server with.
My hooks/post-receive file is executable and contains:
#!/bin/sh
GIT_WORK_TREE=/home/web/website.com/public_html git checkout -f
And my online repo is stored in
/home/web/website.com/website.git
What am I doing wrong?