Having a strange issue with a git post-update hook. I created repository on my server (/var/www/vhosts/git/master.git
) and in this repository added a post-update hook with the following code:
#!/bin/sh
echo $1
echo "*UPDATE*"
case " $1 " in
*'refs/heads/master'*)
GIT_WORK_TREE=/var/www/vhosts/website.com/sandbox.website.com git checkout -f
echo
echo "Master was updated!"
echo
;;
esac
case " $1 " in
*'refs/heads/sandbox'*)
GIT_WORK_TREE=/var/www/vhosts/website.com/sandbox.website.com git checkout -f
echo
echo "Sandbox was updated!"
echo
;;
esac
I made sure this file is executable. Then I created a local repository on my machine using:
$ mkdir website && cd website
$ git init
$ echo 'Testing.' > index.html
$ git add index.html
$ git commit -q -m "Initial commit"
$ git remote add web ssh://username@website.com/var/www/vhosts/website.com/git/master.git
$ git push web +master:refs/heads/master
For whatever reason that first push works just fine—/var/www/vhosts/website.com/sandbox.website.com
gets updated with the index file—but then none of the following pushes work. I get the response back from the post-update
hook that says "Master was updated!" but the directory doesn't actually get updated.
Suggestions?