Hexo提交博客时无法连接GitHub问题排查与求助
解决Hexo部署至GitHub时的连接失败与换行符警告问题
报错信息
warning: in the working copy of 'atom.xml', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'css/hbe.style.css', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'css/main.css', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'css/noscript.css', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'js/FunnyTitle.js', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'js/bookmark.js', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'js/clicklove.js', LF will be replaced by CRLF the next time Git touchesevil小 v,启 stripped探讨:{秘法:Blue/D室技术 lov土 warning: in the working copy of 'js/comments-buttons.js', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'js/comments.js', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'js/config.js', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'js/crypto-js.js', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'js/dytitle.js', LF will be replaced by CRLF the next time Git touches it warning: in the working copy of 'js/excanvas.js', LF will be replaced by CRLF the next time Git touches it fatal: unable to access 'https://github.com/zuquanzhi/myname.github.io.git/': Failed to connect to github.com port 443 after 21102 ms: Couldn't connect to server FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html Error: Spawn failed at ChildProcess.<anonymous> (D:\blog\myblog\node_modules\hexo-util\lib\spawn.js:51:21) at ChildProcess.emit (node:events:517:28) at cp.emit (D:\blog\myblog\node_modules\cross-spawn\lib\enoent.js:34:29) at ChildProcess._handle.onexit (node:internal/child_process:292:12)
已完成的排查操作
- 验证网络连接正常稳定
- 检查并重新配置GitHub SSH密钥,通过
ssh -vT git@github.com排查SSH连接详情 - 排查并临时禁用防火墙、杀毒软件,确认无连接拦截
- 检查Hexo的
_config.yml文件,确保仓库URL配置准确 - 确认GitHub仓库允许SSH连接,且密钥已成功关联至账户
- 确认Hexo版本符合系统要求,更新所有依赖
- 验证GitHub服务状态正常
- 分析错误提示与警告信息
- 检查部署插件与Hexo版本的兼容性
- 确认Git的名称、邮箱配置正确
解决方案
1. 解决换行符警告
这类警告是Git自动转换换行符的配置导致,可通过以下方式关闭自动转换:
- 全局配置(所有Git仓库生效):
git config --global core.autocrlf false - 仅当前Hexo仓库生效:
在博客根目录执行:git config core.autocrlf false
2. 解决GitHub连接失败问题
切换至SSH协议部署
打开Hexo根目录的_config.yml,找到deploy配置块,将HTTPS格式的repo替换为SSH地址:
deploy: type: git repo: git@github.com:zuquanzhi/myname.github.io.git branch: main # 替换为你的仓库默认分支
清除Git代理残留配置
若之前配置过代理,可能导致连接异常,执行以下命令清除:
git config --global --unset http.proxy git config --global --unset https.proxy
验证SSH连接有效性
执行以下命令确认SSH连接正常:
ssh -T git@github.com
返回Hi zuquanzhi! You've successfully authenticated, but GitHub does not provide shell access.则说明连接正常,否则重新检查密钥关联。
重置Hexo部署缓存
清理缓存后重新执行部署流程:
hexo clean hexo generate hexo deploy
内容的提问来源于stack exchange,提问作者zuweicun
相关产品推荐
相关产品推荐

