hexo 部署至Git遇到的坑

查找资料的时候发现了next这个博客主题,next!非常的漂亮,顺手查看了hexo的相关部署。

Hexo官方介绍

Hexo 是一个快速、简洁且高效的博客框架。Hexo 使用 Markdown(或其他渲染引擎)解析文章,在几秒内,即可利用靓丽的主题生成静态网页。
官网 https://hexo.io/zh-cn/docs/index.html

Hexo博客建立

简洁高效,如同官网的介绍。安装过程非常简单,官网有非常详细的文档,安装文档;并且还是中文的哦!

部署至github

安装完成后需要部署至github,根据官网的介绍,首先进行配置
hexo-git配置

安装hexo-delopyer-git

安装hexo关于git管理组件:hexo-delopyer-git,照着做即可

修改配置文件

找到根目录下的_config.yml,修改配置

deploy:
    type: git
    repo: https://github.com/pyrinelaw/pyrinelaw.github.io.git
    branch: master

上传操作

hexo d 

报错spawn git ENOENT

Error: spawn git ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
    at child_process.js:1144:20)
    at process._tickCallback (node.js:355:11)

未添加Git环境变量引起,添加Git与git管理库的环境变量即可;

D:\Git\bin;D:\Git\libexec\git-core

设置完毕后强制更新环境变量,或者重启电脑~

读取不到Git分支

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
cs/troubleshooting.html
Error: fatal: 'github.com/pyrinelaw/pyrinelaw.github.io.git' does not appear
be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

读取不到github上的分支,使用Hexo之前是有使用Git操作过Github的,所以不大可能是Git安装的问题。

ssh -v git@github.com

显示ssh连接github成功,说明Git安装正确。
卸载Git重新安装,错误继续出现。搁置了一天,中午午休的时候网上逛论坛,发现了此问题。原来是我的Git版本太新的缘故。。。
卸载Git 2.5版本,安装1.9版本,问题解决-_-
Paste_Image.png

Git提交错误

再次部署

hexo d 

提示success ~
但是尼玛,居然把整个hexo根目录给提交了上去,这不是我要的结果啊,说好的只提交public文件夹的呢!@Д@
查看hexo根目录,存在“.git”这个目录,原来是在hexo根目录下,我进行过git init的操作,删除“.git”文件夹即可。

Paste_Image.png
至此博客已部署至Github完毕
贴上地址: pyrinelaw.github.io

附:相关查找资料

https://hexo.io/zh-cn/docs/
http://artori.us/git-github-usage/
http://www.jianshu.com/p/858ecf233db9
http://www.cognize.me/2015/08/22/msysgiterror/

posted @ 2015-10-10 09:58  petrus.law  阅读(3356)  评论(3编辑  收藏  举报