Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created June 6, 2017 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jcromartie/26489ecea86338e3a883c83bc6409933 to your computer and use it in GitHub Desktop.
Save jcromartie/26489ecea86338e3a883c83bc6409933 to your computer and use it in GitHub Desktop.
pre-commit hook which fails when untracked files are present in working tree
#!/bin/sh
untrackedFiles=$(git ls-files --others --exclude-standard)
if [ ! -z "$untrackedFiles" ]
then
echo "There are untracked files in the working tree:"
echo "$untrackedFiles"
echo ""
echo "Are you sure you aren't forgetting something?"
echo "Aborting commit..."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment