Skip to content

Instantly share code, notes, and snippets.

@joorloohuis
joorloohuis / pre-commit
Created January 3, 2017 10:20
Git pre-commit hook for syntax checking before committing
#!/bin/bash
#
# PHP Syntax linter, checks syntax before commit actually happens
# Save this file in your git project as .git/hooks/pre-commit and make sure it's executable
# PHP lint command, modify if necessary
LINT='/usr/bin/php -l'
files=$(git diff --cached --name-only --diff-filter=ACM | grep "\.php$")
if [ "$files" = "" ]; then