Created
February 3, 2014 19:47
-
-
Save mschartman/8791014 to your computer and use it in GitHub Desktop.
Pre-commit hook to warn you if you are committing directly 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
if [ "$(git rev-parse --abbrev-ref HEAD)" == "master" ] | |
then | |
exec < /dev/tty | |
read -p "You are on the master branch, are you sure you want to commit? (y/N) " -n 1 -r | |
if [ "$REPLY" = "" ]; then | |
REPLY='N' | |
fi | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
read -p "Are you really sure? (y/N) " -n 1 -r | |
if [ "$REPLY" = "" ]; then | |
REPLY='N' | |
fi | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then | |
echo "Tread lightly...\n" | |
else | |
echo "Aborted.\n" | |
exit 1 | |
fi | |
else | |
echo "Aborted.\n" | |
exit 1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment