电脑重装后恢复上传hexo博客的功能
一:安装Node.js,git,并查看当前软件环境
二:配置SSH key
查看C:\Users\用户名.ssh下有无ssh文件夹,没有则创建
cd ~/. ssh
ssh-keygen -t rsa -C "邮件地址"
打开用户目录,找到.ssh\id_rsa.pub文件,记事本打开并复制里面的内容,打开你的github主页,进入个人设置 -> SSH and GPG keys -> New SSH key:
测试是否成功
ssh -T git@github.com
用户名 邮箱配置
git config --global user.name "pgzxc"// 你的github用户名,非昵称
git config --global user.email "xxx@qq.com"// 填写你的github注册邮箱
三:进入到博客(pgzxc)文件夹删除node_modules public .git .deploy_git,
这一步我在操作时删除反而最后上传博客出错了,最后恢复了文件就可以了
四:关联Github项目
git init
git remote add origin git@github.com:PGzxc/PGzxc.github.io.git
五:运行如下指令”npm install –g hexo ”安装hexo
npm install –g hexo
六:运行如下指令安装项目依赖
npm install
七:hexo -g 生成并本地预览
八:hexo -s 本地预览,在浏览器中输入http://localhost:4000/
九:hexo d 生成并上传
hexo d
十:添加备份
git add .
git commit -m 'modify'
git push origin hexo
————————————————
版权声明:本文为CSDN博主「PGzxc」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Calvin_zhou/article/details/85218157
原博第七八九的步骤我合成了以下命令
hexo clean && hexo generate --deploy
直接把博客推到网页上浏览
使用此命令后我发现新的博文无法传送到网页
是git配置的一个小问题
执行以上命令后有如下报错
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
1.打开项目所在目录,找到隐藏的.git文件夹。注意这个文件夹是隐藏的,显示隐藏出来就行。
2.打开文件夹里的config文件,用sublime或者notepad打开
3.添加这三行并修改到文件:
[user]
name = XXX(用户名称)
email = XXXX(邮箱)
保存后在终端执行
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
亲测可以使用