Skip to content

Instantly share code, notes, and snippets.

@jlecour
Created April 3, 2012 10:10
Show Gist options
  • Save jlecour/2290813 to your computer and use it in GitHub Desktop.
Save jlecour/2290813 to your computer and use it in GitHub Desktop.
Any (executable) "pre-commit" script in .git/hooks is always executed before commiting, so if it returns a non-0 value, it halts the commit. There i put some external scripts, like this one to stop if the commit would be on master directly.
#!/bin/sh
if [[ `git symbolic-ref HEAD` == "refs/heads/master" ]]
then
echo "You cannot commit in master!"
exit 1
fi
#!/bin/sh
set -e
.git/hooks/_no_commit_on_master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment