Skip to content

Instantly share code, notes, and snippets.

@swape
Created May 6, 2015 08:31
Show Gist options
  • Save swape/a8ac8f5cb9b85665cb15 to your computer and use it in GitHub Desktop.
Save swape/a8ac8f5cb9b85665cb15 to your computer and use it in GitHub Desktop.
This git hook is copying the prod branch to prod dir and dev branch to dev dir. Makes it easy to deploy.
#!/bin/bash
echo "-- running post receive --";
while read oldrev newrev ref
do
if [[ $ref =~ .*/dev$ ]];
then
git --work-tree=/var/www/html/dev --git-dir=/home/git/ checkout dev -f
fi
if [[ $ref =~ .*/prod$ ]];
then
git --work-tree=/var/www/html/prod --git-dir=/home/git/ checkout prod -f
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment