Skip to content

Instantly share code, notes, and snippets.

@alecklandgraf
Created June 15, 2015 18:26
Show Gist options
  • Select an option

  • Save alecklandgraf/425ec93cdc225f5f55fd to your computer and use it in GitHub Desktop.

Select an option

Save alecklandgraf/425ec93cdc225f5f55fd to your computer and use it in GitHub Desktop.
git pre-commit hook to prevent committing to master
#!/bin/sh
branch=`git symbolic-ref --short HEAD`
# allow user input within pre-commit hook
exec < /dev/tty
if [ $branch == "master" ]; then
echo "Commit to master [yes|no]?"
read yesno
if [ "$yesno" == "yes" ]; then
echo "commiting"
else
echo "aborting"
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment