Last active
August 29, 2015 14:13
-
-
Save chrisirhc/b3fd4edc6a6ea71de83f to your computer and use it in GitHub Desktop.
pre-push git hook to confirm when 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 | |
IFS=' ' | |
while read local_ref local_sha remote_ref remote_sha | |
do | |
if [ "$remote_ref" = "refs/heads/master" ] | |
then | |
echo "Pushing to master" | |
read -p "You're about to push $local_ref to master, is that what you intended? [y|n] " -n 1 -r < /dev/tty | |
echo | |
if echo $REPLY | grep -E '^[Yy]$' > /dev/null | |
then | |
echo "Proceeding" | |
else | |
exit 1 # push will not execute | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment