我正在与同事合作的一个项目使用 husky 版本 ^5.1.0,当我尝试推送我的提交时,我不断收到此错误。
.husky/_/husky.sh: No such file or directory
我该如何解决这个问题?
我目前使用的是 git 版本 2.18.0。
我已经提到了https://github.com/typicode/husky/issues/712和https://github.com/typicode/husky/issues/242但没有多大帮助。
我通过删除
node_modules
并运行解决了这个问题:
yarn install
但是,这在提交中添加了
.husky/_/husky.sh
,这是我的同事不想要的。为了解决这个问题,我通过 Homebrew 更新了 Git:
brew update && brew upgrade
这将 Git 更新到了版本 2.30.2,这使得嵌套的
.gitignore
能够正确忽略 .husky/_/husky.sh
文件。
在我当前的场景中,我能够解决运行
npx husky-init
的问题并放弃对文件所做的所有更改。
删除文件后可以使用此命令:_/husky.sh
git config --unset core.hooksPath
如果这可以帮助与我有同样问题的人
我在以下代码中
.husky/commit-msg
npx --no -- commitlint --edit "${1}"
只需删除
"
,它对我有用,即
npx --no -- commitlint --edit ${1}
您可能已删除此文件。要正确重新实例化它,请运行
npx husky install
。
它不仅会添加
husky.sh
,还会在.gitignore
中添加必要的_
。