Created
October 5, 2015 14:21
-
-
Save florian-wagner/0be0b09bbabec6791ed3 to your computer and use it in GitHub Desktop.
Git-hook giving a warning when you try to push to the '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
#!/bin/bash | |
# Save this file as gimli/.git/hooks/pre-push and make it executable. | |
protected_branch='master' | |
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') | |
if [ $protected_branch = $current_branch ] | |
then | |
read -p "GIMLi encourages developers to push only to the 'dev' branch. You're about to push to 'master', is that what you intended? [y|n] " -n 1 -r < /dev/tty | |
echo | |
if echo $REPLY | grep -E '^[Yy]$' > /dev/null | |
then | |
exit 0 | |
fi | |
exit 1 | |
else | |
exit 0 | |
fi |
Author
florian-wagner
commented
Oct 5, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment