#!/bin/bash # git hook while read oldrev newrev ref do # only checking out the master (or whatever branch you would like to deploy) if [[ $ref =~ .*/master$ ]]; then echo "Master ref received. Deploying master branch to production..." git --work-tree=/home/beuthbot/BeuthBotServer/ --git-dir=/home/beuthbot/BeuthBotServer.git/ checkout -f cd /home/beuthbot/BeuthBotServer/ ./scripts/deployment.sh else echo "Ref $ref successfully received. Doing nothing: only the master branch may be deployed on this server." fi done