在项目中,我们使用Husky,但是当我尝试使用git添加提交时。和git提交-m“测试”,我收到以下错误
..husky/预提交: 2::无法打开..husky/_/.husky.‘t

我怎样才能解决这个问题?
我的操作系统是Windows,但我在这个项目上使用了Ubuntu
我有一个预提交文件,如下所示

此外,husky.sh的代码如下
if [ -z "$husky_skip_init" ]; then
debug () {
if [ "$HUSKY_DEBUG" = "1" ]; then
echo "husky (debug) - $1"
fi
}
readonly hook_name="$(basename "$0")"
debug "starting $hook_name..."
if [ "$HUSKY" = "0" ]; then
debug "HUSKY env variable is set to 0, skipping hook"
exit 0
fi
if [ -f ~/.huskyrc ]; then
debug "sourcing ~/.huskyrc"
. ~/.huskyrc
fi
export readonly husky_skip_init=1
sh -e "$0" "$@"
exitCode="$?"
if [ $exitCode != 0 ]; then
echo "husky - $hook_name hook exited with code $exitCode (error)"
fi
exit $exitCode
fi发布于 2022-02-07 20:52:29
对于这个问题,我提出了如下的解决办法。在我的IDE中,行尾默认使用CRLF。所以我把它从IDE的右下角改为LF,它起作用了。

https://stackoverflow.com/questions/71021328
复制相似问题