#!/bin/bash cd ~/ PATH=$(pwd) REPO="$PATH/project.git" TRAGET="$PATH/deploy-folder" BRANCH="live" while read oldrev newrev ref do # only checking out the master (or whatever branch you would like to deploy) if [[ $ref =~ .*/"${BRANCH}"$ ]]; then echo "Ref $ref received. Deploying ${BRANCH} branch to production..." git --work-tree=${TRAGET} --git-dir=${REPO} checkout -f else echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." fi done