使用husky时如何解决.husky/_/husky.sh: No such file or directory错误?

问题描述 投票:0回答:4

我正在与同事合作的一个项目使用 husky 版本 ^5.1.0,当我尝试推送我的提交时,我不断收到此错误。

.husky/_/husky.sh: No such file or directory

我该如何解决这个问题?

我目前使用的是 git 版本 2.18.0。

我已经提到了https://github.com/typicode/husky/issues/712https://github.com/typicode/husky/issues/242但没有多大帮助。

git husky git-husky
4个回答
11
投票

我通过删除

node_modules
并运行解决了这个问题:

yarn install

但是,这在提交中添加了

.husky/_/husky.sh
,这是我的同事不想要的。为了解决这个问题,我通过 Homebrew 更新了 Git:

brew update && brew upgrade

这将 Git 更新到了版本 2.30.2,这使得嵌套的

.gitignore
能够正确忽略
.husky/_/husky.sh
文件。


7
投票

在我当前的场景中,我能够解决运行

npx husky-init
的问题并放弃对文件所做的所有更改。


2
投票

删除文件后可以使用此命令:_/husky.sh

git config --unset core.hooksPath

0
投票

如果这可以帮助与我有同样问题的人

我在以下代码中

.husky/commit-msg

npx --no -- commitlint --edit "${1}"

只需删除

"
,它对我有用,即
npx --no -- commitlint --edit ${1}

© www.soinside.com 2019 - 2024. All rights reserved.