Skip to content

Instantly share code, notes, and snippets.

@iamdustan
Created January 10, 2014 20:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save iamdustan/8362447 to your computer and use it in GitHub Desktop.
Save iamdustan/8362447 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