Create a gist now

Instantly share code, notes, and snippets.

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