Skip to content

Instantly share code, notes, and snippets.

@ashimaathri
Last active April 8, 2016 19:08
Show Gist options
  • Save ashimaathri/f9a01ed9406e7fd76e3ff83de68fc0a3 to your computer and use it in GitHub Desktop.
Save ashimaathri/f9a01ed9406e7fd76e3ff83de68fc0a3 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Remember to make this file executable and place it in .git/hooks with the name pre-push
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
echo "You were going to push to master and I can't allow that. Disable this hook if you really want to continue."
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