当前位置: 首页 > 工具软件 > pre-commit > 使用案例 >

git commit报错 pre-commit 报错

翟沈义
2023-12-01

报错信息

guchejia_web_app git:(5.1.1) ✗ git commit -am "[feat]: 修改弹窗"
Warning: Setting commit-msg script in package.json > scripts will be deprecated
Please move it to husky.hooks in package.json, a .huskyrc file, or a husky.config.js file
Or run ./node_modules/.bin/husky-upgrade for automatic update

See https://github.com/typicode/husky for usage

husky > commit-msg (node v8.9.0)
⧗   input: [feat]: 修改弹窗
✖   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 failed (add --no-verify to bypass)
➜  guchejia_web_app git:(uicheck) ✗ git status
On branch uicheck
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

 

原因

在终端输入git commit -am "**",提交代码

会触发pre-commit的钩子,他会在Git提交信息之前先做代码风格的检测

如果不符合相应规则,会报错

它的检测规则就是根据.git/hooks/pre-commit文件里面的相关定义

 

解决方案

提交代码commit时,忽略pre-commit校验的钩子,加上参数--no-verify

8 files changed, 5657 insertions(+), 5612 deletions(-)
2. 删除.git/hooks下的的pre-commit文件,重新commit
3. 卸载husky
 类似资料: