git commit报错(husky commit-msg hook failed)
2020/10/10 14:03:42
本文主要是介绍git commit报错(husky commit-msg hook failed),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
报错信息
➜ 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) modified: npm-shrinkwrap.json modified: src/page/weibaochaxun/app.tsx modified: src/page/weibaochaxun/components/dialog/index.tsx modified: src/page/weibaochaxun/components/dialog/style.scss modified: src/page/weibaochaxun/components/payResultToast/index.tsx modified: src/page/weibaochaxun/components/payResultToast/style.scss modified: src/page/weibaochaxun/pages/tcDetail/index.tsx modified: src/page/weibaochaxun/weibaochaxun.html ➜ guchejia_web_app git:(uicheck) ✗ git push origin uicheck warning: redirecting to http://***/guchejia_web_app.git/ Everything up-to-date
原因
- 在终端输入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
➜ guchejia_web_app git:(5.1.1) ll .git/hooks
total 264
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 applypatch-msg
-rwxr-xr-x 1 a96 staff 478B 10 10 2019 applypatch-msg.sample
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 commit-msg
-rwxr-xr-x 1 a96 staff 896B 10 10 2019 commit-msg.sample
-rwxr-xr-x 1 a96 staff 3.2K 10 10 2019 fsmonitor-watchman.sample
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 post-applypatch
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 post-checkout
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 post-commit
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 post-merge
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 post-receive
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 post-rewrite
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 post-update
-rwxr-xr-x 1 a96 staff 189B 10 10 2019 post-update.sample
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 pre-applypatch
-rwxr-xr-x 1 a96 staff 424B 10 10 2019 pre-applypatch.sample
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 pre-auto-gc
-rwxrwxrwx 1 a96 staff 88B 10 9 15:13 pre-commit
-rw-r--r-- 1 a96 staff 106B 10 9 15:13 pre-commit.old
-rwxr-xr-x 1 a96 staff 1.6K 10 10 2019 pre-commit.sample
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 pre-merge-commit
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 pre-push
-rwxr-xr-x 1 a96 staff 1.3K 10 10 2019 pre-push.sample
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 pre-rebase
-rwxr-xr-x 1 a96 staff 4.8K 10 10 2019 pre-rebase.sample
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 pre-receive
-rwxr-xr-x 1 a96 staff 544B 10 10 2019 pre-receive.sample
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 prepare-commit-msg
-rwxr-xr-x 1 a96 staff 1.5K 10 10 2019 prepare-commit-msg.sample
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 push-to-checkout
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 sendemail-validate
-rwxr-xr-x 1 a96 staff 1.4K 10 9 15:13 update
-rwxr-xr-x 1 a96 staff 3.5K 10 10 2019 update.sample
3. 卸载husky
这篇关于git commit报错(husky commit-msg hook failed)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-20前端项目部署入门:简单教程让你轻松上手
- 2024-09-20如何轻松创建和使用动态表格
- 2024-09-20初学者指南:动态菜单项处理入门教程
- 2024-09-20富文本编辑器入门教程:轻松上手指南
- 2024-09-20前端项目部署:新手入门完全指南
- 2024-09-20TagsView标签栏导航课程:新手入门详解
- 2024-09-19前端项目部署课程:新手入门教程
- 2024-09-19云开发让 Unity 微信小游戏实时聊起来
- 2024-09-15前后端分离教程:入门级实战指南
- 2024-09-13谷歌浏览器驱动入门:轻松掌握自动化测试基础