执行以下命令

1
hexo cl && hexo generate && hexo server

假如报以下错误:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
warning: in the working copy of 'tags/飞牛/index.html', LF will be replaced by CRLF the next time Git touches it
On branch master
nothing to commit, working tree clean
ssh: connect to host github.com port 22: Connection refused
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
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\lele\node_modules\hexo-deployer-git\node_modules\hexo-util\lib\spawn.js:51:21)
at ChildProcess.emit (node:events:524:28)
at cp.emit (D:\blog\lele\node_modules\cross-spawn\lib\enoent.js:34:29)
at ChildProcess._handle.onexit (node:internal/child_process:293:12)

注意上边ssh: connect to host github.com port 22: Connection refused这个错误,然后执行下边的命令

1
ssh -vT git@github.com

假如输出:

1
2
3
4
5
6
7
8
$ ssh -vT git@github.com
OpenSSH_9.0p1, OpenSSL 1.1.1o 3 May 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to github.com [::1] port 22.
debug1: connect to address ::1 port 22: Connection refused
debug1: Connecting to github.com [127.0.0.1] port 22.
debug1: connect to address 127.0.0.1 port 22: Connection refused
ssh: connect to host github.com port 22: Connection refused

从上面的信息马上就发现了诡异的地方,连接http://github.com的地址居然是::1127.0.0.1。前者是IPV6的localhost地址,后者是IPV4的localhost地址,这说明错误的原因是DNS解析被污染了,修改windows的host文件即可解决,host文件路径在C:\Windows\System32\drivers\etc,进去找到host用记事本打开,添加github对应的dns即可解决

1
20.205.243.166       github.com

github对应的dns可以去下边这个网站去找

https://dnschecker.org/

修改后保存,再允许下边代码可解决

1
hexo cl && hexo generate && hexo server

参考教程