Skip to content

Instantly share code, notes, and snippets.

@eddywashere
Last active March 25, 2017 00:38
Show Gist options
  • Save eddywashere/107b33b35601d21b1a2a to your computer and use it in GitHub Desktop.
Save eddywashere/107b33b35601d21b1a2a 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