【问题标题】:githooks(5): what is the Git "null-ref"githooks(5):什么是 Git “null-ref”
【发布时间】:2022-07-16 06:35:48
【问题描述】:

post-checkout hook 的文档中,它说

它也在git-clone[1] 之后运行,除非使用了--no-checkout (-n) 选项。给钩子的第一个参数是 null-ref,第二个参数是新 HEAD 的 ref,标志始终为 1。git worktree add 也是如此,除非使用了--no-checkout

这里的“null-ref”指的是什么?

【问题讨论】:

    标签: git githooks


    【解决方案1】:

    我在~/.config/git/template/hooks/post-checkout 中添加了以下行:

    echo "post-checkout" "$@" 1>&2
    

    然后克隆一个新的存储库,得到以下输出:

    post-checkout 0000000000000000000000000000000000000000 4abcac4ddfb69f6dfde1af0164f2f0ee0e230336 1
    

    所以看起来post-checkout 脚本中的“null-ref”是0000000000000000000000000000000000000000

    (这个问题背后的背景是我想设置一个特殊的 per-repo Git config user.email 值,仅当我从我工作的 Gitlab 服务器克隆存储库时。)

    【讨论】:

      猜你喜欢
      • 2015-06-15
      • 1970-01-01
      • 2022-07-02
      • 1970-01-01
      • 2020-09-25
      • 2014-07-26
      • 1970-01-01
      • 1970-01-01
      • 2016-09-24
      相关资源
      最近更新 更多