Created
February 8, 2016 12:57
-
-
Save valo/759f4003fc1271b618da to your computer and use it in GitHub Desktop.
Git hook: protect the master branch from pushing to it
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
#!/bin/bash | |
protected_branch='master' | |
current_branch=$(git symbolic-ref --short HEAD) | |
if [ $protected_branch = $current_branch ] | |
then | |
echo "Direct commits to the branch master are not allowed" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment