Created
January 20, 2016 11:58
-
-
Save tamsanh/783a62adeba81ba47999 to your computer and use it in GitHub Desktop.
Don't run if git is dirty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ITERATING=0 | |
MASTER_ONLY=0 | |
if [ $ITERATING -ne 1 ] | |
then | |
git diff-index --quiet HEAD | |
if [ $? -ne 0 ] | |
then | |
echo "!!! There are untracked changes. You must commit before running this script." | |
echo "Will not allow running until you resolve the following files:" | |
echo | |
git diff-index HEAD | |
echo | |
echo "To commit these files, use the following command:" | |
echo "git commit -m \"<Reason why you're committing>\" -a" | |
echo | |
exit 1 | |
fi | |
if [[ "`git rev-parse --abbrev-ref HEAD`" != "master" && $MASTER_ONLY -eq 1 ]] | |
then | |
echo "!!! You are not on the master branch. You cannot run this cript unless you are on master" | |
echo "To get to the master branch, use the following command:" | |
echo "git checkout master" | |
echo | |
exit 1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment