Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pre-commit/hook: No such file or directory

I get this error when I try to commit.

OS - Latest OSX

Git version - git version 2.11.0 (Apple Git-81)

.git/hooks/pre-commit: line 2: ./node_modules/pre-commit/hook: No such file or directory 
like image 324
Jitendra Vyas Avatar asked May 12 '17 08:05

Jitendra Vyas


People also ask

How do I enable pre-commit hook?

Open a terminal window by using option + T in GitKraken Client. Once the terminal windows is open, change directory to . git/hooks . Then use the command chmod +x pre-commit to make the pre-commit file executable.

How do you bypass pre-commit hook?

Use the --no-verify option to skip git commit hooks, e.g. git commit -m "commit message" --no-verify . When the --no-verify option is used, the pre-commit and commit-msg hooks are bypassed.

What is pre-commit hook in git?

The pre-commit hook is run first, before you even type in a commit message. It's used to inspect the snapshot that's about to be committed, to see if you've forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.

Where does pre-commit install hooks?

pre-commit by default places its repository store in ~/. cache/pre-commit -- this can be configured in two ways: PRE_COMMIT_HOME : if set, pre-commit will use that location instead.


Video Answer


2 Answers

pre-commit hook runs first when you try to commit changes, it can be used to do certain checks, tests, conditions. In this case, clearly, you don't have it, that's why it's complaining.

Go to .git/hooks directory and remove pre-commit file, as its trying to reference to node_modules/pre-commit/hook. It should resolve it.

Other option is append your commit with option: --no-verify, it will make the commit without checking.

like image 78
Mutant Avatar answered Sep 18 '22 12:09

Mutant


You should delete node_modules folder and install again running npm install or yarn install. After it, you probably solve the problem.

like image 37
Gerson Lima Avatar answered Sep 20 '22 12:09

Gerson Lima