Skip to content

Instantly share code, notes, and snippets.

@thibaultcha
Created May 9, 2014 04:30
Show Gist options
  • Save thibaultcha/82e8e58d986ff6332d28 to your computer and use it in GitHub Desktop.
Save thibaultcha/82e8e58d986ff6332d28 to your computer and use it in GitHub Desktop.
Used to detect a forbidden pattern that you don't want to commit
FILES_PATTERN='\.(js|coffee)(\..+)?$'
FORBIDDEN='console.log'
git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n $FORBIDDEN && echo "COMMIT REJECTED. Found $FORBIDDEN references. Please remove them before commiting" && exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment