【问题标题】:Any way to put my hook to github repo?有什么方法可以将我的钩子放到 github repo 上吗?
【发布时间】:2016-03-04 20:49:33
【问题描述】:

我可以实现它,以便在从 github 拉出一个 repo 后,钩子已经存在于 .git/hooks 目录中吗?

【问题讨论】:

    标签: github hook


    【解决方案1】:

    不是直接的,因为那会带来安全风险(你不知道那些钩子脚本在做什么)

    你可以试试:

    • 在你的 git repo 中对代表你的钩子的文件(或多个文件)进行版本化
    • version a .gitattribute 声明了一个 content filter driversmudge 脚本),它将在 git checkout 上触发。
    • smudge 脚本中,将这些文件复制到您的.git/hooks

    (图片来自“Customizing Git - Git Attributes”,来自“Pro Git book”)

    但即使在这种情况下,您也需要先使用git config 命令激活smudge 过滤器(可以是全局配置,所以在克隆存储库之前完成)

    git config --global filter.hooks.smudge 'script_to_copy_hooks'
    

    【讨论】:

      猜你喜欢
      • 2018-10-06
      • 2015-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-05
      • 2021-07-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多