core.hooksPath 可以有多个目录吗?
Can we have multiple directories for core.hooksPath?
似乎如果我在全局配置文件~/.gitconfig
中设置core.hooksPath
,$GIT_DIR/hooks
中的钩子将不会被执行。
我们可以同时在这两个文件夹运行中挂钩吗?
没有。您需要选择其中之一或两者都不选。这些文件夹可能有同名的挂钩。如果两者都生效,应该调用哪个?
在您的情况下,默认情况下,将调用全局 core.hooksPath
定义的挂钩。
调用$GIT_DIR/hooks
、
中的那些
# for permanent
# the local config has higher precedence than the global config
git config core.hooksPath $(git rev-parse --absolute-git-dir)/hooks
git some_command
# for once
git -c core.hooksPath=.git/hooks some_command
两者都不调用,
# for permanent
git config core.hooksPath <some_path_without_hooks>
git some_command
# for once
git -c core.hooksPath=<some_path_without_hooks> some_command
似乎如果我在全局配置文件~/.gitconfig
中设置core.hooksPath
,$GIT_DIR/hooks
中的钩子将不会被执行。
我们可以同时在这两个文件夹运行中挂钩吗?
没有。您需要选择其中之一或两者都不选。这些文件夹可能有同名的挂钩。如果两者都生效,应该调用哪个?
在您的情况下,默认情况下,将调用全局 core.hooksPath
定义的挂钩。
调用$GIT_DIR/hooks
、
# for permanent
# the local config has higher precedence than the global config
git config core.hooksPath $(git rev-parse --absolute-git-dir)/hooks
git some_command
# for once
git -c core.hooksPath=.git/hooks some_command
两者都不调用,
# for permanent
git config core.hooksPath <some_path_without_hooks>
git some_command
# for once
git -c core.hooksPath=<some_path_without_hooks> some_command