Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.