Skip to content

Instantly share code, notes, and snippets.

@3ffusi0on
Created January 2, 2016 12:22
Show Gist options
  • Save 3ffusi0on/27562d864f011957e822 to your computer and use it in GitHub Desktop.
Save 3ffusi0on/27562d864f011957e822 to your computer and use it in GitHub Desktop.
Git hook post-update
#!/bin/sh
#
# Hook on repository update managing two branches dev and master
# in order to supervise production and development environnement.
#
echo $1
echo "*Updating repository using Hook*"
case " $1 " in
*'refs/heads/dev'*)
GIT_WORK_TREE=/var/www/html/dev/ git checkout dev -f
echo "Dev environnement updated."
;;
esac
case " $1 " in
*'refs/heads/master'*)
GIT_WORK_TREE=/var/www/html/prod/ git checkout master -f
echo "Master environnement updated."
;;
esac
@3ffusi0on
Copy link
Author

Git hook used to execute different task depending on the branch which received the commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment