Skip to content

Instantly share code, notes, and snippets.

@hikoma
Created August 3, 2017 06:18
Show Gist options
  • Save hikoma/13d8806ea9d455cf6d5afc84877c87a2 to your computer and use it in GitHub Desktop.
Save hikoma/13d8806ea9d455cf6d5afc84877c87a2 to your computer and use it in GitHub Desktop.
Git pre-push hook
#!/usr/bin/env bash
while read local_ref local_sha1 remote_ref remote_sha1
do
if [[ "${remote_ref##refs/heads/}" =~ (master|develop) ]]; then
exec < /dev/tty
read -p "Push to ${remote_ref##refs/heads/}? [Y/n] " answer
if [[ "${answer}" =~ ^[Yy] ]]; then
exit
fi
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment