Skip to content

Instantly share code, notes, and snippets.

@chrisirhc
Last active August 29, 2015 14:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisirhc/b3fd4edc6a6ea71de83f to your computer and use it in GitHub Desktop.
Save chrisirhc/b3fd4edc6a6ea71de83f to your computer and use it in GitHub Desktop.
pre-push git hook to confirm when pushing to master
#!/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