Skip to content

Instantly share code, notes, and snippets.

@musically-ut
Last active August 14, 2016 05:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save musically-ut/7bcd78cce3aa226d7f62ce71555ee010 to your computer and use it in GitHub Desktop.
Save musically-ut/7bcd78cce3aa226d7f62ce71555ee010 to your computer and use it in GitHub Desktop.
Pre-commit hook to avoid committing lines with '#NO-GIT"
#!/bin/sh
PAT='#\s*NO(.)?GIT'
git diff --cached --name-only | \
xargs egrep -i --color --with-filename -n "$PAT" && echo "Found '"$PAT"' in code about to be committed. Rejecting commit." && exit 1
# Exit with error code zero if all went well.
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment