Solve the GIT commit error and bypass the code check

Svn was used in the last project and git was used in the new project. I was very happy and finally learned GIT. I thought I had learned git, but I still encountered a problem that was not within the scope of my knowledge points. Finally, my colleagues helped solve it

Question: when the code commits for the first time, it always reports errors. After reading the error information, it seems that the code errors will be checked before committing, but the code has no errors. Can it run?Will the errors checked by eslint be checked out, and then the commit fails?Finally, I found a solution on the Internet


first, let’s get to know git’s hook:

Hooks are stored in the hooks subdirectory under the GIT directory. That is. Git/hooks in most projects. When initializing a new version library with git init, GIT will place some sample scripts in this directory by default. In addition to being called by themselves, these scripts also reveal the parameters passed in when triggered. All the examples are shell scripts, some of which are mixed with Perl code, but any properly named executable script can be used normally


  GIT_DIR/hooks/pre-commit  :

This hook is called by the GIT commit command and can be skipped by adding the — no verify parameter to the command. This hook requires no parameters and is called before getting the commit message and starting the commit. If the return value of the hook is not 0, the GIT commit command will abort execution

Note: this hook can be used to check for code errors before submitting (for example, running a lint program)

When the default pre commit hook is enabled, if it finds a blank line at the end of the file, it will abort the submission


Similar Posts: