Skip to content

Instantly share code, notes, and snippets.

@vikeri
Created August 2, 2019 08:16
Show Gist options
  • Save vikeri/202674c0bc272291b7f854af66b438a9 to your computer and use it in GitHub Desktop.
Save vikeri/202674c0bc272291b7f854af66b438a9 to your computer and use it in GitHub Desktop.
Prevent commit on master branch
#!/bin/sh
#
# 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
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment