Git commit hooks per branch Git commit hooks per branch git git

Git commit hooks per branch


in a post-commit hook you could do the following:

if [ `git rev-parse --abbrev-ref HEAD` == "development" ]; then   echo "development-script"elif [ `git rev-parse --abbrev-ref HEAD` == "staging" ]; then   echo "staging-script"elif [ `git rev-parse --abbrev-ref HEAD` == "production" ]; then   echo "production-script"fi


I had written a script for myself to do this functionality.

https://github.com/fotuzlab/githubdump-php

Host this file on your server, preferably repo root and define the url in github webhooks. Change 'allcommits' on line 8 with your branch name and add your code/function at line 18.

You will need separate files and webhooks for all your 3 instances.

Hope this helps!