【问题标题】:Location of shell script file, which is to be executed by local git hookshell脚本文件位置,本地git hook执行
【发布时间】:2012-04-13 13:25:09
【问题描述】:

我第一次使用git hooks 并遇到了一个看似简单但到目前为止我还没有找到任何答案的问题。

我创建了一个 shell 脚本(直接调用时它工作正常),我想在 git post-commit-hook 中调用它。我知道我可以将脚本本身包含在挂钩中,但如果添加更多脚本,这可能会变得混乱。

挂钩文件的内容如下所示:

!/bin/sh

sh myshellscript.sh # This doesn't work by the way

: Nothing

钩子确实被执行了,但是没有找到myshellscript.sh

放置 myshellscript.sh 的最佳位置在哪里以及如何引用它?

提前致谢!

【问题讨论】:

    标签: git shell githooks


    【解决方案1】:

    钩子将在当前目录设置为$GIT_DIR 的情况下执行,这通常是存储库的根目录。

    如果您的脚本 myshellscript.sh 位于您需要运行的 hooks 目录中

    sh .git/hooks/myshellscript.sh
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多