Skip to content

Instantly share code, notes, and snippets.

@stephencroberts
Last active December 27, 2015 17:29
Show Gist options
  • Save stephencroberts/7362094 to your computer and use it in GitHub Desktop.
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
#!/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