Aby obsłużyć Push to musimy w pliku repo.git/hooks/post-receive na naszym serwerze umieścić ten kod:
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=/path/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi
if [ "dev" == "$branch" ]; then
git --work-tree=/path/root/dir/dev-site/ checkout -f $branch
echo 'Changes pushed to dev.'
fi
done
Teraz za każdym razem kiedy przyjdzie PUSH, to zamiast kierować tylko mastera w jedno miejsce, to sterujemy odpowiednio innymi branch`ami.
