Skip to content

Instantly share code, notes, and snippets.

@visor
Created September 3, 2013 15:31
Show Gist options
  • Save visor/6425487 to your computer and use it in GitHub Desktop.
Save visor/6425487 to your computer and use it in GitHub Desktop.
pre-commit hook
#!/usr/bin/bash
FORBIDDEN='var_export\|error_log\|console\.log'
git diff --cached --name-only \
| grep -E '\.(js|php|css)$' \
| GREP_COLOR='4;5;37;41' xargs grep --color --with-filename -n -e $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