任何方式把我的钩github回购? [英] Any way to put my hook to github repo?

查看:131
本文介绍了任何方式把我的钩github回购?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能否实现它,以便在从github提取回购后,钩子存在于 .git / hooks 目录中?

解决方案

不是直接的,因为这会代表安全风险(您不知道这些钩子脚本在做什么)

<您可以尝试:


  • 版本一个文件(或多个文件)代表您的git仓库中的钩子$ / $>


  • (图片来自定制Git - Git属性,来自 Pro Git book



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

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


    Can I achieve it so that after pulling a repo from github the hooks has existed in .git/hooks directory?

    解决方案

    Not directly, as that would represent a security risk (you don't know what those hook scripts are doing)

    You can try and:

    • version a file (or files) representing your hooks in your git repo
    • version a .gitattribute declaring a content filter driver (smudge script), which will trigger on git checkout.
    • in that smudge script, copy those files into your .git/hooks

    (image from "Customizing Git - Git Attributes", from "Pro Git book")

    But even in that case, you would need to activate that smudge filter with a git config command first (which can be a global config, so done before cloning the repo)

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

    这篇关于任何方式把我的钩github回购?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆