Last active
August 29, 2015 14:18
-
-
Save segadora/ab010e216e23ad7dab59 to your computer and use it in GitHub Desktop.
Prevent commit on master branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Based on https://gist.github.com/Simbul/1781656 | |
# This pre-commit hook will prevent any commit to forbidden branch | |
# (by default, "master"). | |
# Put this file in your local repo, in the .git/hooks folder | |
# and make sure it is executable. | |
# The name of the file *must* be "pre-commit" for Git to pick it up. | |
current_branch=`git rev-parse --abbrev-ref HEAD` | |
if [ $current_branch = 'master' ] ;then | |
echo | |
echo " STOP THE PRESS!" | |
echo " You are trying to commit on the $current_branch branch." | |
echo " Surely you don't mean that?" | |
echo | |
echo " If you really do, force the commit by adding --no-verify to the command." | |
echo | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment