git diff during pre-commit hook results in Not a git repository

后端 未结 2 1872
梦毁少年i
梦毁少年i 2021-01-06 09:41

I\'m trying to build a pre-commit script in git. In that script I plan on running tasks if a certain folder has changed. To test, in my script I have

git d         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-06 09:52

    Even though GIT_DIR is set, I would still try a:

    git --git-dir=/full/path/to/repo/.git --work-tree=/full/path/to/rpeo diff --cached |grep -q "^my/folder" 
    

    That way, you are sure the hook is executed where it is supposed to.

提交回复
热议问题