尝试提交时出现奇怪的错误。[主题-空]

Ben*_*lan 5 husky

我在 CLI 中输入这个

git commit -m "Hello World!"
Run Code Online (Sandbox Code Playgroud)

这是我收到的错误消息

husky > commit-msg (node v14.15.3)
?   input: Hello World!
?   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)
Run Code Online (Sandbox Code Playgroud)

这是什么意思?

use*_*491 84

要修复该错误,请更改提交消息(“Hello world”)以遵循常规提交格式,例如“feat:hello world”。

正如“获取帮助”消息链接(在错误消息中)所解释的那样,husky 调用commitlint来验证您的提交消息是否符合此格式。

我们应该始终使用RTFEM


GoT*_*oTo 25

对我来说这是一个空间。改变了

`feat(pill):message here` 
Run Code Online (Sandbox Code Playgroud)

`feat(pill): message here`
Run Code Online (Sandbox Code Playgroud)

有一个名为 husky 的包,它为您的提交消息定义了特定的模板。如果不满足模板,就会出现奇怪的错误。


Ash*_*wat 25

您可以尝试的另一个解决方案是

git commit --no-verify -m "Hello World!"

git commit -n -m "Hello World!"

参考

  1. Git 挂钩 ( https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks )
  2. 检查常规提交
  3. 什么是提交 lint设置


Ben*_*lan 16

我用“npm uninstall husky”解决了这个问题

编辑:在删除它之前,请确保您知道它的作用并且您的项目不会使用它。

  • 如果你不知道它的作用,你不应该卸载软件包,在这种情况下,husky 授予提交约定,请花点时间阅读 https://www.conventionalcommits.org/en/v1.0.0/ 并且https://typicode.github.io/husky/#/ (9认同)