相关疑难解决方法(0)

Git钩子:应用`git config core.hooksPath`

我有一个带有预提交钩子的git存储库:

my-repo
|- .git
   |- hooks
      |- pre-commit     # I made this file executable
Run Code Online (Sandbox Code Playgroud)

一直到那里,一切正常.我提交时挂钩正在运行.

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

我现在跑git config core.hooksPath ./git-config/hooks进去了my-repo.

文件夹结构是这样的:

my-repo
|- .git
   |- hooks
|- git-config
   |- hooks
      |- pre-commit     # I made this file executable as well
Run Code Online (Sandbox Code Playgroud)

会发生什么:

  • 新的预提交脚本不会在提交时运行
  • 如果我保留它,旧的预提交脚本仍会在提交时运行 my-repo/.git/hooks
  • git config --get core.hooksPathmy-repo输出中运行./git-config/hooks

如何在提交时运行新的预提交钩子?

以下是我显然不太了解的文档的链接:
https://git-scm.com/docs/git-config
https://git-scm.com/docs/githooks

git githooks

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

git ×1

githooks ×1