Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Git pre-commit hook to prevent commits to master branch
# Check to see if we are on master branch. Stop accidental commits
if [ $(git symbolic-ref HEAD 2>/dev/null) == "refs/heads/master" ]
echo "Cannot commit to master branch"
exit 1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment