Git post-fetch hook doesn't work after push

I have a website hosted on an Amazon EC2 instance (running Ubuntu 12.04). I want 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 called post-receive containing:

#!/bin/sh
GIT_WORK_TREE=/home/ubuntu/beta git checkout -f

      

The file has permissions: -rwxrwxr-x (i.e. it is executable).

On my local machine, when I push to a git repo on the server, the push succeeds and the git repository is updated. However, the hook does not start after receiving. If I run the hook manually, it works fine and updates the working directory.

The git push is done over SSH and uses the same user as if I ran the hook manually.

Any ideas why the hook isn't starting automatically?

Thank.

+3


source to share


1 answer


I have installed a local identical test (i.e. I cloned from a local folder) and it works fine.

To see if the script is being executed at all, I added a simple tap to see if it modifies any files.

My post-trick looks like this



#!/bin/sh

touch /Users/raven/git_tests/live/.git/hooks/i_ve_been_run
GIT_WORK_TREE=/Users/raven/git_tests/live git checkout -f

      

Make sure your hook is named accurately post-receive

or it won't work.

+3


source







All Articles