Skip to content

Instantly share code, notes, and snippets.

@doctyper
Created November 12, 2011 02:10
Show Gist options
  • Save doctyper/1359906 to your computer and use it in GitHub Desktop.
Save doctyper/1359906 to your computer and use it in GitHub Desktop.
Check to see if we are on master branch. Stop accidental commits
#!/bin/sh
# Check to see if we are on master branch. Stop accidental commits
if [ $(git symbolic-ref HEAD 2>/dev/null) == "refs/heads/master" ]
then
if [ -f i_want_to_commit_to_master ]
then
rm i_want_to_commit_to_master
exit 0
else
echo "Cannot commit to master branch"
echo "Remember to create file 'touch i_want_to_commit_to_master' to commit to master"
fi
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment