300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > git commit报错(husky > commit-msg hook failed)

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

时间:2019-03-21 17:52:45

相关推荐

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 deprecatedPlease move it to husky.hooks in package.json, a .huskyrc file, or a husky.config.js fileOr run ./node_modules/.bin/husky-upgrade for automatic updateSee /typicode/husky for usagehusky > 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: /conventional-changelog/commitlint/#what-is-commitlinthusky > commit-msg hook failed (add --no-verify to bypass)➜ guchejia_web_app git:(uicheck) ✗ git statusOn branch uicheckChanges to be committed:(use "git reset HEAD <file>..." to unstage)modified: npm-shrinkwrap.jsonmodified: src/page/weibaochaxun/app.tsxmodified: src/page/weibaochaxun/components/dialog/index.tsxmodified: src/page/weibaochaxun/components/dialog/style.scssmodified: src/page/weibaochaxun/components/payResultToast/index.tsxmodified: src/page/weibaochaxun/components/payResultToast/style.scssmodified: src/page/weibaochaxun/pages/tcDetail/index.tsxmodified: 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

➜ guchejia_web_app git:(5.1.1) ✗ git commit --no-verify -am "[feat]:修改维保查询弹窗"[5.1.1 da8c2c0] [feat]:修改维保查询弹窗8 files changed, 5657 insertions(+), 5612 deletions(-)

删除.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 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 commit-msg.sample-rwxr-xr-x 1 a96 staff 3.2K 10 10 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 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 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 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 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 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 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 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 update.sample

卸载husky

总结:以上几种方法都是在commit提交时忽略代码规则校验。建议在codeing的过程中可以经常运行一下代码校验修整命令,不要把校验都放在提交的环节

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。