I have set up a two bare git repository's on my server with file paths like so:
/git/project.git/
/git/project2.git/
I then have added two branches dev and live. I then added the following post-receive hook to each project
`
#!/bin/sh
while read oldrev newrev refname
do
echo "STARTING [$oldrev $newrev $refname]"
if [ "$refname" == 'refs/heads/dev' ]
then
GIT_WORK_TREE=/var/www/vhosts/devwebsite.com/httpdocs/ git checkout -f
elif [ "$refname" == 'refs/heads/live' ]
then
GIT_WORK_TREE=/var/www/vhosts/livewebsite.com/httpdocs/ git checkout -f
fi
done`
This works on 1 project but not the other. On the second project it only seems to work with my first file I pushed which happens to be a .gitignore file.
So in short this file is the only file that will be updated when I push.