You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法执行Git Commit至GitHub:commitlint配置报错求助

解决Commitlint因空规则拦截Git Commit的问题

你遇到的是commitlint未配置校验规则导致的提交拦截,husky触发commitlint钩子时,发现你的commitlint.config.js没有定义任何规则,所以抛出错误终止提交。

解决步骤:

  • 安装官方标准规则包
    根据你使用的包管理器执行对应命令:

    # 使用yarn
    yarn add @commitlint/config-conventional --dev
    
    # 使用npm
    npm install @commitlint/config-conventional --save-dev
    
  • 配置commitlint规则
    在项目根目录的commitlint.config.js文件中添加以下内容:

    module.exports = {
      extends: ['@commitlint/config-conventional']
    };
    
  • 重新执行提交
    现在可以正常运行commit命令,例如:

    git commit -m "chore: add commitlint on commit-msg"
    

内容的提问来源于stack exchange,提问作者Blaze Lapiito

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 20:45:57