#!/bin/bash BRANCH ="master" REPO ="~/project.git" TRAGET ="~/deploy-folder" LOG ="~/logs/deploy-master.log" NOW =$(date +"%Y-%m-%d-%H:%M:%S") 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 successfully received. Doing nothing: only the ${BRANCH} branch may be deployed on this server." fi done