I have a website hosted on an Amazon EC2 instance (running Ubuntu 12.04). I want to be able to be able to push changes to the server using git and then use a post-receive hook to checkout in the working directory. So on the server in the hooks directory I have a file named post-receive containing:
#!/bin/sh
GIT_WORK_TREE=/home/ubuntu/beta git checkout -f
The file has the permissions: -rwxrwxr-x (i.e. it is executable).
On my local machine, when I push to the git repo on the server, the push is successful and the git repo is updated. The post-receive hook is not run, however. If I run the hook manually, it runs fine and updates the working directory.
The git push is carried out over SSH and uses the same user as if I were running the hook manually.
Any ideas why the hook will not run automatically?
Thanks.
I've set up an local identical test (ie I cloned from a local folder) and it works fine.
To see if the script is executed at all I've added a simple touch to see if it modifies any files
My post-receive looks like this
Make sure that your hook is named exactly
post-receive
or it won't work.