Skip to content

Instantly share code, notes, and snippets.

Created Aug 2, 2019
What would you like to do?
Prevent commit on master branch
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
# To enable this hook, rename this file to ".git/hooks/pre-commit".
if [ $(git rev-parse --abbrev-ref HEAD) == "master" ] ; then
echo "\033[1;31mCan't commit directly to master\033[0m"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment