hexo + github 配置及错误解决

下个月开始要准备找工作了,所以最近需要建个博客,这样到时候面试就可以show一手啦。但素呢,特喵的!!!hexo+github搭建,可以说非常简单,也可以说是非常难。整整用了我一天的时间,所以我必须要记录一下。免得以后再次出错忘记怎么弄了。
【此教程默认已安装git Bash,nodejs,且已注册github,并绑定ssh key】

文档是宝典,多看

#正常模式(对于电脑第一次安装部署hexo的)

  1. 在github上创建一个仓库,名字为
    1
    silvia-YQY.github.io

可默认添加README.md

  1. 电脑安装hexo
    1
    2
    3
    4
    5
    $ npm install hexo-cli -g          //全局安装hexo客户端
    $ hexo init blog //创建一个blog的文件夹,并且hexo初始化改文件夹
    $ cd blog //进入blog文件夹
    $ npm install //安装hexo需要的包
    $ hexo server //打开hexo服务器,默认端口为4000;

此时本地的hexo已经部署完毕,在浏览器搜索 : http://localhost:4000,已经可以查看博客

  1. 部署hexo到github上面

    • 安装hexo-deployer-git

      1
      $ npm install hexo-deployer-git --save
    • 修改blog文件夹下面的yml文件

1
2
3
4
5
deploy:
type: git
repo: git@github.com:silvia-YQY/silvia-YQY.github.io.git
branch: master
message: blog
  • 重新生成并部署
1
2
$ hexo generate
$ hexo deploy

注:无须将blog文件夹里面安装silvia-YQY.github.io仓库的文件夹内,而且无须git push 上传。只需要安装hexo-deployer-git,并运行hexo deploy ,该插件会自动将文件部署到silvia-YQY.github.io仓库内。

切记!!!不要把hexo的blog文件夹复制过去silvia-YQY.github.io仓库,silvia-YQY.github.io仓库无须操作任何事情!!!血的教训

此时本地的hexo已经在github部署完毕,在浏览器搜索 : https://silvia-yqy.github.io,已经可以查看博客

此为不知道为何会出问题的解决办法

由于之前在家里弄,全部已经部署完毕了,并且可以正常运行。但是更新文章的时候,可能是手贱,上传文件上传错了,而且自己也傻逼的把文件复制过去仓库了,所以,哎~

  1. hexo deploy 错误
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    nothing to commit, working directory clean
    Permission denied (publickey).
    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: [http://hexo.io/docs/troubleshooting.html](http://hexo.io/docs/troubleshooting.html)

    Error: Permission denied (publickey). // 此为重点!!!!

    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.

该错误,跟着官方文档做就好。

在hexo文件夹内进行一下操作,期间若需要输入密码,就输入密码吧

  • 1.1
    1
    sh -T git@github.com

没出错后

  • 1.2
    1
    eval "$(ssh-agent -s)"

正确应该为

1
2
3
$ ssh -T git@github.com
Enter passphrase for key '/c/Users/Administrator/.ssh/id_rsa':
Hi silvia-YQY! You've successfully authenticated, but GitHub does not provide shell access.

  • 1.3
    1
    2
    $ eval "$(ssh-agent -s)"
    Agent pid 2556
  • 1.4
    1
    2
    $ ssh-add -l -E md5
    4096 MD5:7a:fa:c3:4e:cf:1a:91:b7:d0:5d:45:79:90:b4:d8:03 /c/Users/Administrator/.ssh/id_rsa (RSA)

下面的md5码出现为正常,若出现一下情况

agent has no identities.```
1
2
3

则先去C:\Users\Administrator\.ssh删除known_hosts文件,然后运行
```$ ssh-add ~/.ssh/id_rsa

此为正确信息

1
2
3
$ ssh-add ~/.ssh/id_rsa
Enter passphrase for /c/Users/Administrator/.ssh/id_rsa:
Identity added: /c/Users/Administrator/.ssh/id_rsa (/c/Users/Administrator/.ssh/id_rsa)

正确后,再次运行

ssh-add -l -E md5```
1
2
出现md5码为一斤绑定权限成功。
此时可以顺利的 ```$ hexo deploy

×

纯属好玩

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. 此为不知道为何会出问题的解决办法
,