Skip to content

Instantly share code, notes, and snippets.

@markmur
Created March 14, 2016 16:17
Show Gist options
  • Save markmur/2fade5df60b8183583fa to your computer and use it in GitHub Desktop.
Save markmur/2fade5df60b8183583fa to your computer and use it in GitHub Desktop.
Git Pre Push
#!/bin/bash
protected_branch='master'
current_branch=$(git symbolic-ref --short HEAD)
if [ $protected_branch = $current_branch ]
then
read -p "You should create a PR rather than push to master. Are you absolutely sure you want to proceed? [y/n]" -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
then
exit 0 # push will execute
fi
exit 1 # push will not execute
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