Skip to content

Instantly share code, notes, and snippets.

@tjboudreaux
Forked from eddywashere/pre-commit
Created November 26, 2015 04:17
Show Gist options
  • Save tjboudreaux/8544508db44f91c7ff32 to your computer and use it in GitHub Desktop.
Save tjboudreaux/8544508db44f91c7ff32 to your computer and use it in GitHub Desktop.
Git hook that prevents commits to master
#!/bin/sh
#
# Git hook that prevents commits to master
# use --no-verify to bypass this hook
# ex: git commit -m "init commit" --no-verify
branch=`git symbolic-ref HEAD`
if [ "$branch" = "refs/heads/master" ]; then
echo "Direct commits to the branch master are not allowed"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment