git commit 报错:No staged files match any configured task.
> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - [34m→[39m No staged files match any configured task. ⧗ input: feat: XXX ✖ subject may not be empty [subject-empty] ✖ type may not be empty [type-empty] ✖ found 2 problems, 0 warnings ⓘ Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint husky - commit-msg hook exited with code 1 (error) 这就涉及到 git hooks 了,熟悉的小伙伴自不用多说,不熟悉的可以看一下官方文档:Git - Git 钩子
如果报错中有 husky、commitlint 这样的关键字眼,那就是前端项目中使用了这两种 npm 插件,husky 的配置文件在如下截图位置:

# 注释掉最后一行(不建议,急用临时提交可行)#!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" npx --no -- commitlint --edit ${1} 若是使用 JetBrains公司的系列产品时(
WebStrom/PhpStrom/IDEA…),可以:去掉勾选(不限前端项目)
package.json 和 node_modules 该依赖是否安装:{ "devDependencies": { "@commitlint/cli": "^17.4.4", "@commitlint/config-conventional": "^17.4.4", "husky": "^8.0.3", }, } 我这里最终发现问题就出现在这里(
package.json在某次代码合并中被不知名小可爱覆盖。。。刚好缺了commitlint)
若是内网开发,规范可见源码:
node_modules\@commitlint\config-conventional\index.js
node_modules ,然后重新 npm i 试试over