Skip to content

Instantly share code, notes, and snippets.

@lgelfan
Forked from eddywashere/pre-commit
Created March 25, 2017 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgelfan/bad9d199afb4fc4434a605e1b3e47a44 to your computer and use it in GitHub Desktop.
Save lgelfan/bad9d199afb4fc4434a605e1b3e47a44 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