Skip to content

Instantly share code, notes, and snippets.

@othree
Last active March 15, 2017 03:54
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 othree/a5ad2dd81a5957a06867 to your computer and use it in GitHub Desktop.
Save othree/a5ad2dd81a5957a06867 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Stops accidental commits to master and develop. https://gist.github.com/stefansundin/9059706
# Install:
# cd path/to/git/repo
# curl -fL -o https://gist.githubusercontent.com/othree/a5ad2dd81a5957a06867/raw/3abf8b2fbc9ce614af83e2522f23c163c78c97c6/Not%2520commit%2520to%2520master
# chmod +x .git/hooks/pre-commit
BRANCH=`git rev-parse --abbrev-ref HEAD`
if [[ "$BRANCH" == "master" ]]; then
echo "You are on branch $BRANCH. Are you sure you want to commit to this branch?"
echo "If so, commit with -n to bypass this pre-commit hook."
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment