Git hooks : applying `git config core.hooksPath`

梦想的初衷 提交于 2019-12-21 07:38:58

问题


I have a git repository with a pre-commit hook set up :

my-repo
|- .git
   |- hooks
      |- pre-commit     # I made this file executable

Until there, everything works. The hook is running when I commit.

=================================

I now run git config core.hooksPath ./git-config/hooks in my-repo.

The folder structure is this one :

my-repo
|- .git
   |- hooks
|- git-config
   |- hooks
      |- pre-commit     # I made this file executable as well

What happens is :

  • the new pre-commit script doesn't run on commit
  • the old pre-commit script still runs on commit if I leave it in my-repo/.git/hooks
  • running git config --get core.hooksPath in my-repo outputs ./git-config/hooks

How can I make the new pre-commit hook run on commit ?

Here's the link to the docs I apparently don't understand well :
https://git-scm.com/docs/git-config
https://git-scm.com/docs/githooks


回答1:


The core.hooksPath support is new in Git version 2.9, having been put in with commit 867ad08a2610526edb5723804723d371136fc643. If your Git version is not at least 2.9.0, setting a hooks-path variable will have no effect at all.



来源:https://stackoverflow.com/questions/39332407/git-hooks-applying-git-config-core-hookspath

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!