aborting git pre-commit hook when var_dump present
问题 I am trying (but failing miserably) to make a git pre-commit hook that checks for the presence of a var_dump in my modified files and exits if it finds one. The problem that I'm having is that it appears to always be aborting the commit. Here is the contents of my pre-commit file: VAR=$(git diff | grep -w "var_dump") if [ -z $VAR ]; then echo "You've left a var_dump in one of your files! Aborting commit..." exit 1 fi 回答1: First of all, note that plain git diff gives the difference between the