Skip to content

Instantly share code, notes, and snippets.

@shaneog
Created October 10, 2014 22:57
Show Gist options
  • Save shaneog/779e754153ee816ed226 to your computer and use it in GitHub Desktop.
Save shaneog/779e754153ee816ed226 to your computer and use it in GitHub Desktop.
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