git 预提交/挂钩:没有这样的文件或目录

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43933490/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:58:01  来源:igfitidea点击:

pre-commit/hook: No such file or directory

gitpre-commit-hookpre-commit

提问by Jitendra Vyas

I get this error when I try to commit.

当我尝试提交时出现此错误。

OS - Latest OSX

操作系统 - 最新的 OSX

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

Git 版本 - git 版本 2.11.0 (Apple Git-81)

.git/hooks/pre-commit: line 2: ./node_modules/pre-commit/hook: No such file or directory

回答by Mutant

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/hooksdirectory and remove pre-commitfile, as its trying to reference to node_modules/pre-commit/hook. It should resolve it.

转到.git/hooks目录并删除pre-commit文件,因为它试图引用node_modules/pre-commit/hook. 它应该解决它。

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

另一个选项是使用 option: 附加您的提交--no-verify,它将在不检查的情况下进行提交。

回答by Gerson Lima

You should delete node_modulesfolder and install again running npm installor yarn install. After it, you probably solve the problem.

您应该删除node_modules文件夹并再次安装运行npm installyarn install。之后,您可能会解决问题。