repo-local-git-hooks
解决本地钩子被全局配置覆盖导致 CI/本地校验失效的常见痛点。
会修改 Git 钩子或配置,需谨慎以免破坏开发环境设置。
检测并修复因全局 core.hooksPath 绕过仓库本地 Git 钩子的问题。
检测并修复因全局 core.hooksPath 绕过仓库本地 Git 钩子导致的 lint/格式/测试失效,常见于 macOS 被 nix-darwin/home-manager 注入全局 hooks 的环境。适用于 .git/hooks 存在但被忽略、pre-commit 无法安装或 CI 放行本应拦截的提交时。提供审计脚本并能恢复为优先使用本地钩子的状态。
▸ 展开 SKILL.md 英文原文
Detect and repair cases where repository-local Git hooks are bypassed by a global core.hooksPath, especially on macOS machines managed by nix-darwin/home-manager that inject global gitleaks/git-hooks paths. Use when CI catches lint/format/test issues that pre-commit or pre-push should have caught, when .git/hooks exists but Git ignores it, when installing pre-commit refuses because core.hooksPath is set, or when a repo needs local pre-commit/pre-push hooks to override global hooks.
帮我安装这个 skill:https://raw.githubusercontent.com/Eotel/skills/main/repo-local-git-hooks/SKILL.mdcurl -fsSL "https://raw.githubusercontent.com/Eotel/skills/main/repo-local-git-hooks/SKILL.md"# Repo Local Git Hooks Use this skill when a repo expects local hooks but Git is using a global `core.hooksPath`. The common symptom is: `.git/hooks/pre-commit` exists, yet commits/pushes run only a global Nix/gitleaks hook or no repo-specific lint at all. ## Audit First Run the bundled audit script from the target repo: ```bash path/to/repo-local-git-hooks/scripts/audit_git_hooks.sh ``` Or inspect manually: ```bash git config --show-origin --get-all core.hooksPath || true git rev-parse --git-common-dir git rev-parse --git-path hooks ``` Interpretation: - `git rev-parse --git-path hooks` must match `$(git rev-parse --git-common-dir)/hooks` when repo-local `.git/hooks` should be effec