Last active
December 27, 2015 17:29
-
-
Save stephencroberts/7362094 to your computer and use it in GitHub Desktop.
Checks that staging has no modified or untracked files before allowing a push
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
#!/bin/bash | |
cd ../ | |
unset GIT_DIR | |
read rev_old rev_new refname | |
if [[ "$refname" == *master* ]] | |
then | |
echo "Checking staging for modified/untracked files..." | |
git diff --name-only --exit-code | |
rc=$? | |
if [ -z "`git ls-files -o --exclude-standard`" ] && [ $rc -eq 0 ] | |
then | |
echo "Staging is clean, continuing..." | |
else | |
echo "Please commit changes on staging first" | |
exit 1 | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment