【问题标题】:How to check only new commits on update git hook on server?如何仅检查服务器上更新 git 挂钩的新提交?
【发布时间】:2020-06-25 08:41:52
【问题描述】:

到目前为止,我使用 git 服务器上的 update 钩子来检查提交中的消息。

当添加 new 分支时,我会得到参数 refs/heads/mybranch 00000...0000 <headShaOfBranch>

如何仅检查尚未在存储库中的提交?这样做的程序是什么? (这样做是不是错误的钩子?)

如果我采用0000<headShaOfBranch> 的范围,我会检查从<headShaOfBranch> 开始的每个提交,这是不好的。

【问题讨论】:

    标签: git githooks


    【解决方案1】:

    使用git rev-list:

    git rev-list "refs/heads/mybranch" --not --exclude "refs/heads/mybranch" --all
    

    将输出从refs/heads/mybranch 开始的所有提交,所有引用集合--all 不包括refs/heads/mybranch

    注意--exclude-all 之前。见docs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-14
      • 1970-01-01
      • 2017-07-12
      • 2012-10-18
      • 2016-04-02
      • 2012-06-10
      • 2013-02-07
      相关资源
      最近更新 更多