重装系统hexo博客重装

标题安装hexo环境

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm

查看nodejs和npm版本号,验证是否安装完成

nodejs -v
npm -v

安装 Hexo

在原hexo博客目录下安装

sudo npm install -g hexo-cli

测试是否安装成功

hexo server

到http://localhost:4000下查看服务器是否正常启动

关联github

参考 首先生成ssh秘钥

ssh-keygen -t rsa -C "youremail@example.com"

查看所生成的秘钥(其地址在上述创建命令后的有展示)

show 秘钥文件

复制本地ssh秘钥到github上重新创建一个,然后检验

ssh -T git@github.com

显示下列文字代表关联成功

The authenticity of host github.com (207.97.227.239) cant be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?  # 直接输入yes
Hi cnfeat! Youve successfully authenticated, but GitHub does not provide shell access

然后就可以hexo g/hexo d了

标题遇到的问题

关联秘钥成功后,hexo d报错:

fatal: LF would be replaced by CRLF in 2020/07/18/AVLTree/index.html
FATAL Somethings wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
    at ChildProcess.<anonymous> (/mnt/d/git/git_tutorial/work/blog/hexo/node_modules/hexo-util/lib/spawn.js:51:21)
    at ChildProcess.emit (events.js:315:20)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)

解决参考 运行下列命令后解决

git config --global core.autocrlf false

问题原因:

git在windows下,默认是CRLF作为换行符,git add 提交时,检查文本中有LF 换行符(linux系统里面的),则会告警。所以问题的解决很简单,让git忽略该检查即可

经验分享 程序员 微信小程序 职场和发展