1、 Problem with git commit – M ‘xxx’
Today, I encountered a problem during the commit phase when uploading a project. Whether uploading in sourcetree or using the command git commit - M 'xxx'
, I reported the following error:
husky > npm run -s precommit (node v8.12.0)
husky > pre-commit hook failed (add --no-verify to bypass)
I checked many methods later, but they didn’t solve them very well. But it can probably summarize the problem:
Disaster caused by pre commit hook
When you enter git commit - M "XXX"
on the terminal and submit the code,
Pre commit (client) hook, which will run to check the code style before git types the submission information
If the code does not comply with the corresponding rules, an error is reported.
Although Add -- no verify
will be prompted, I enter git commit - M 'xxx' -- no verify
to bypass verification and force submission. It still doesn’t seem to upload successfully. If you do the same
Please look below
2、 ‘weak chicken’ solution
In order to save some trouble, I didn’t spend time to find out where the code didn’t meet the specification. I violently deleted the pre commit
hook to font>!
Specific steps:
Enter the. Git folder of the project (the folder is hidden by default. You can set the display or command ls to find it first)
Then enter the hooks folder
Delete pre commit file
Re git commit - M 'xxx'
git push
. Sourcetree can also be pushed normally
To sum up: delete the submission rule file of. Git: RM - RF./git/hooks/pre commit
Last word of advice: This is a last resort. If it is a daily development or a good code specification, now the code will generally be verified by eslint
. If you feel troublesome, you can install a prettier plug-in to help you format the code