Git挂钩:应用`git config core.hooksPath` [英] Git hooks : applying `git config core.hooksPath`
问题描述
我有一个设置了预提交钩子的git存储库:
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.
================================
=================================
我现在在my-repo
中运行git config core.hooksPath ./git-config/hooks
.
文件夹结构是这个:
my-repo
|- .git
|- hooks
|- git-config
|- hooks
|- pre-commit # I made this file executable as well
会发生什么:
- 新的预提交脚本无法在提交时运行
- 如果我将其保留在
my-repo/.git/hooks
中,则旧的预提交脚本仍会在提交时运行
- 在
my-repo
中运行git config --get core.hooksPath
输出./git-config/hooks
- 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
inmy-repo
outputs./git-config/hooks
如何使新的预提交挂钩在提交时运行?
这是我显然不太了解的文档的链接:
https://git-scm.com/docs/git-config
https://git-scm.com/docs/githooks
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
推荐答案
core.hooksPath
支持为提交867ad08a2610526edb5723804723d371136fc643
.如果您的Git版本不低于2.9.0,则设置一个hooks-path变量根本无效.
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.
这篇关于Git挂钩:应用`git config core.hooksPath`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!