Last active
August 29, 2015 14:17
-
-
Save mihai/cf32f741b1bce3280e76 to your computer and use it in GitHub Desktop.
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/sh | |
# Prevent pushing to `protected_branch`. | |
# Just place this file in your `.git/hooks` folder and make sure it is executable | |
protected_branch='master' | |
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
if [ $protected_branch = $current_branch ] | |
then | |
echo "You're pushing to master, that is NOT ALLOWED" | |
echo | |
exit 1 # push will not execute | |
else | |
exit 0 # push will execute | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment