刘勇虎的官方网站
网站内容包含大前端、服务器开发、Python开发、iOS开发、Android开发、网站维护等技术文章。专注于分享技术经验,职业心得体会,IT优秀文章与教程创作。
Stay hungry,Stay foolish,Stay young
Tips: 如果是 clone 下来的新项目直接进行 步骤 4 。
.git/hooks/pre-commit 或其他钩子脚本的开头可能包含无效的 Shebang 行(如 #!/bin/sh -/)或语法错误。.git/hooks 文件夹:cd .git/hooks
pre-commit 文件(或其他钩子)的开头行:head -n 1 pre-commit
#!/bin/sh 或 #!/usr/bin/env sh,删除多余的符号(如 -/)。- /path/to/node 的无效参数,需修正为合法命令(如 node script.js)。bash git commit --no-verify -m "提交信息" node -v#!/usr/bin/env node)。chmod +x .git/hooks/pre-commit
.git/hooks 目录:bash rm -rf .git/hooks bash npx husky install bash npx husky add .husky/pre-commit "npm test" 确保 Git 全局配置正确(虽非直接原因,但需排除干扰):
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
总结步骤优先级:
--no-verify 提交 → 快速绕过。