Skip to content

Instantly share code, notes, and snippets.

@joaocunha
Forked from iamdustan/pre-commit
Last active August 29, 2015 14:10
Show Gist options
  • Save joaocunha/de641a9fe800e4e1d859 to your computer and use it in GitHub Desktop.
Save joaocunha/de641a9fe800e4e1d859 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Prevent commits against the 'master' branch
if [[ `git rev-parse --abbrev-ref HEAD` == 'master' ]]
then
echo 'You cannot commit to the master branch!'
echo 'Stash your changes and apply them to another branch, using:'
echo 'git stash'
echo 'git checkout <branch>'
echo 'git stash apply'
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment