Skip to content

Instantly share code, notes, and snippets.

@AtomicSmash
Created February 16, 2014 17:10
Show Gist options
  • Save AtomicSmash/9037362 to your computer and use it in GitHub Desktop.
Save AtomicSmash/9037362 to your computer and use it in GitHub Desktop.
This is an example of a GIT "post-receive" hook that check the branch name before deploying
#!/bin/bash
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
git --work-tree=/var/www/domain.com --git-dir=/home/git/repositories/root/testproject.git checkout -f
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment