#!/bin/bash
TARGET="/home/webuser/deploy-folder"
GIT_DIR="/home/webuser/www.git"
BRANCH="master"
while read oldrev newrev ref
do
branch=$(git rev-parse --symbolic --abbrev-ref $ref)
# only checking out the master (or whatever branch you would like to deploy)
if [ "$branch" = "$BRANCH" ];
then
echo "Ref $ref received. Deploying ${BRANCH} branch to test04"
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
else
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
fi
done
~
~