Created
November 11, 2013 10:33
-
-
Save Prinzhorn/7411142 to your computer and use it in GitHub Desktop.
pre-push hook to prevent pushing when untracked files are present. i.e. breaking your production server because you forgot to add a new file in your commit and the tests run locally inside the repo.
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
git status --porcelain | grep '^??' | |
rc=$? | |
#grep exits with 0 when a match is found. | |
if [ $rc = 0 ] ; then | |
echo "Untracked files present. Aborting push."; | |
exit 1; | |
fi | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Your gist helped me, thanks !
I think, i've improved it
Plus,
git status --porcelain
is not only for untracked file but also for uncommited files 😸Bye,