In the process of pre-receive, I get the fatal: This operation must be run in a work tree
exception while hit the pre-receive
hook. I am sure the hook is hitting, Becasue I can print my own message by that hook.
#!/usr/bin/env bash
FILES=`git diff --name-only --diff-filter=d HEAD~1`
for COMMIT in $FILES;
do
case $COMMIT in
*.txt|*.pdf|*.docx)
echo "Hello there! We have restricted committing that filetype.
exit 1
;;
esac
done
exit 0
Whether my hook code is wrong or any other issue? but this hook is running perfecly.