在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 –