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

后端 未结 2 1845
梦毁少年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.

    0 讨论(0)
  • 2021-01-06 10:07

    unset GIT_DIR cleared it up. I'm disappointed that --git-dir did not.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题