Skip to content

Instantly share code, notes, and snippets.

@kdimatteo
Created October 22, 2014 17:10
Show Gist options
  • Save kdimatteo/eeed7a8788c1544e72aa to your computer and use it in GitHub Desktop.
Save kdimatteo/eeed7a8788c1544e72aa to your computer and use it in GitHub Desktop.
Disallow force pushing to master
#!/bin/bash
# this file is ./git/hooks/pre-push
protected_branch='master'
current_branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
if [ $protected_branch = $current_branch ]
then
echo "y u do this? (You can not push to master)"
exit 1;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment