Skip to content

Instantly share code, notes, and snippets.

@daniel-nelson
Last active February 19, 2021 18:01
Show Gist options
  • Save daniel-nelson/6fcd4fe798b9cd340529e1a88fd70bf4 to your computer and use it in GitHub Desktop.
Save daniel-nelson/6fcd4fe798b9cd340529e1a88fd70bf4 to your computer and use it in GitHub Desktop.
Confirm before pushing to production repositories. Place in .git/hooks/ and make executable
#!/bin/bash
if [[ "$1" =~ "production" ]]; then
read -a array
pushed_ref=${array[1]}
remote_ref=${array[3]}
echo
echo "# Commits:"
git log --oneline $remote_ref...$pushed_ref
echo
echo
read -p "Really push to production? If yes, type 'production' " -r < /dev/tty
echo
if [[ $REPLY = 'production' ]]; then
exit 0
else
exit 1
fi
else
exit 0 # push will execute
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment