在pre-receive的过程中,我得到fatal: This operation must be run in a work tree
异常,同时点击pre-receive
挂钩。我确定钩子正在击中,因为我可以通过钩子打印我自己的消息。致命:此操作必须在预接收钩子上的工作树上运行
#!/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
无论我的钩子代码是错误还是其他问题?但this hook正在运行。
也许相关:https://stackoverflow.com/questions/25638767/git-diff- on-a-bare-repo –