Last active
August 29, 2019 07:38
-
-
Save vikeri/ade27cd96f1e1b32d67f3739d9d7d752 to your computer and use it in GitHub Desktop.
Prevent from pushing to master
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 | |
# Copy to .git/hooks/pre-push | |
# Run chmod +x .git/hooks/pre-push | |
protected_branch='master' | |
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
if [ $protected_branch = $current_branch ] | |
then | |
echo "you can't push directly to master" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment