GitKraken推送失败:pre-push钩子报错(退出码1)求助
GitKraken推送特定分支时触发Pre-push钩子失败:系统找不到指定路径
推送本地demo分支到远程时,反复出现以下错误提示:
'Pre-push hook failed: Git hook exited with 1'
错误日志显示:
'The System cannot find the path specified. Hook process exited.'
环境信息
- Git版本:v2.41.0(最初为v2.38.1)
- Git LFS版本:v3.3.0(最初为v3.2.0)
- Git客户端:GitKraken 9.5.1(2023年6月20日更新,最初为8.10.1)
- 操作系统:Windows 10家庭版
问题详情
仓库已初始化Git LFS且整体工作正常,但仅在推送demo分支时触发错误,其他分支(master、main、development)推送无异常。
demo分支基于development分支创建,目的是隔离同事在development分支的未提交改动。首次尝试推送创建远程demo分支时触发错误,后续即使手动在GitHub上创建了远程demo分支,推送仍失败。
已尝试的修复操作
- 未修改过
.git/hooks/pre-push文件,多次强制更新钩子、删除后重新创建该文件,钩子内容如下:
command -v git-lfs >/dev/null 2>&1 || { echo >&2 " This repository is configured for Git LFS but 'git-lfs' was not found on your path. If you no longer wish to use Git LFS, remove this hook by deleting '.git/hooks/pre-push'. "; exit 2; } git lfs pre-push "$@"
- 尝试将远程origin的URL从
https://github.com/<username>/<project>.git改为git@github.com/<username>/<project>.git,但GitKraken持续要求输入SSH凭据,不想为此项目配置SSH,改回原URL后问题依旧。 - 完全重新安装GitKraken,更新Git和Git LFS到最新版本,问题仍未解决。
- 通过终端推送
demo分支无任何错误,仅GitKraken客户端推送时触发钩子错误,甚至同时出现提交后钩子和pre-push钩子错误,日志信息与之前一致。
仓库Git配置文件内容
bare = false repositoryformatversion = 0 filemode = false symlinks = false ignorecase = true logallrefupdates = true [remote "origin"] url = https://github.com/<omitted>/<omitted>.git fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master [branch "main"] remote = origin merge = refs/heads/main [lfs] repositoryformatversion = 0 [filter "lfs"] required = true clean = git-lfs clean -- %f smudge = git-lfs smudge -- %f process = git-lfs filter-process [lfs "https://github.com/<omitted>/<omitted>.git/info/lfs"] access = basic [branch "development"] remote = origin merge = refs/heads/development [branch "demo"] remote = origin merge = refs/heads/demo
内容的提问来源于stack exchange,提问作者Kreateer
相关产品推荐
相关产品推荐

