1. 首页

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

原因

  1. 在终端输入git commit -am “**”,提交代码时
  2. 会触发pre-commit的钩子,他会在Git提交信息之前先做代码风格的检测
  3. 如果不符合相应规则,会报错
  4. 它的检测规则就是根据.git/hooks/pre-commit文件里面的相关定义

解决方案

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

8 files changed, 5657 insertions(+), 5612 deletions(-)
  1. 删除.git/hooks下的的pre-commit文件,重新commit
    > Js中文网 – 前端进阶资源教程 www.javascriptC.com,typescript 中文文档
    > 一个帮助开发者成长的社区,你想要的,在这里都能找到

➜ 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
  1. 卸载husky

作者:浅夏晴空
链接:https://segmentfault.com/a/1190000037412875

看完两件小事

如果你觉得这篇文章对你挺有启发,我想请你帮我两个小忙:

  1. 关注我们的 GitHub 博客,让我们成为长期关系
  2. 把这篇文章分享给你的朋友 / 交流群,让更多的人看到,一起进步,一起成长!
  3. 关注公众号 「画漫画的程序员」,公众号后台回复「资源」 免费领取我精心整理的前端进阶资源教程

JS中文网是中国领先的新一代开发者社区和专业的技术媒体,一个帮助开发者成长的社区,目前已经覆盖和服务了超过 300 万开发者,你每天都可以在这里找到技术世界的头条内容。欢迎热爱技术的你一起加入交流与学习,JS中文网的使命是帮助开发者用代码改变世界

本文著作权归作者所有,如若转载,请注明出处

转载请注明:文章转载自「 Js中文网 · 前端进阶资源教程 」https://www.javascriptc.com

标题:git commit报错(husky > commit-msg hook failed)

链接:https://www.javascriptc.com/4280.html

« 新手后端Nginx必备
强烈推介的几个微信小程序开发小技巧,简单又实用»
Flutter 中文教程资源

相关推荐

QR code