【问题标题】:Is there a way to only skip the commit-msg hook有没有办法只跳过 commit-msg 钩子
【发布时间】:2021-12-04 15:44:40
【问题描述】:

我已经检查了 commit-msg 钩子中的提交消息,我有时想跳过它。我知道该任务有一个git commit --no-verify,但这也跳过了预提交挂钩。有没有办法只跳过 commit-msg 钩子而不是预提交?

【问题讨论】:

    标签: git github git-commit pre-commit-hook


    【解决方案1】:

    不,但也可以:

    • Git 没有为此提供机制。
    • Git 不编写提交挂钩。 编写提交钩子。

    因此,编写您的 commit-msg 钩子,以便它检查某种控制旋钮:“如果控制旋钮设置为一种方式,请检查提交消息;如果设置为另一种方式,则接受提交消息”。

    您现在的任务是选择控制旋钮并确保它在正确的时间以正确的方式设置。一个明显的可能性是一个简单的环境变量:

    $ SKIP_MESSAGE_CHECK=yes git commit -m "silly message"
    

    (假设是 sh/bash 样式的 shell;如果需要,请使用 env SKIP_MESSAGE_CHECK=yes ...)。

    【讨论】:

      猜你喜欢
      • 2020-12-11
      • 1970-01-01
      • 1970-01-01
      • 2010-10-24
      • 2018-07-28
      • 1970-01-01
      • 2022-06-16
      • 2013-02-17
      • 1970-01-01
      相关资源
      最近更新 更多