hexo 部署至Git遇到的坑

作者: PetrusLaw | 来源:发表于2015-09-26 09:17 被阅读20375次

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

Hexo官方介绍

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

Hexo博客建立

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

部署至github

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


hexo-git配置

安装hexo-depoyer-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/

相关文章

网友评论

  • Alince_:git 1.9 的 包谁有呢?或者链接也行 qq:1146818803 邮箱:yaqianghan_827@163.com
    谢谢!!!
  • Oct1a:现在为什么不会自动跳转https,http链接都打不开
  • Obeing:你好,上传成功却浏览却是404是怎么回事。https://github.com/sally2015/sally2015;应该是要访问https://sally2015.github.io这个地址吧
    PetrusLaw:@Obeing 配置文件里面的地址是不是配错了
  • 6e4990c6c67f:“安装hexo-delopyer-git
    安装hexo关于git管理组件:hexo-delopyer-git,照着做即可”

    哥哥你的deployer拼错了。果然是坑。坑死我
    PetrusLaw:@6e4990c6c67f 有时候打字稍微块了一点。。。
  • jianghu000:$ hexo d
    INFO Deploying: git
    INFO Clearing .deploy_git folder...
    INFO Copying files from public folder...
    warning: The behavior of 'git add --all (or -A)' with no path argument from a
    subdirectory of the tree will change in Git 2.0 and should not be used anymore.
    To add content for the whole tree, run:

    就是报错,求救大神啊·····
    PetrusLaw:@71ab3e8efe5c 你看一下你的hexo目录下是不是有个 .git 的文件夹,如果有删除掉,然后重新执行一下
  • MapleShao:你没发现你每次提交代码的时候,没办法加注释么,而且把上一次的注释都给覆盖了
  • 83443bba530a:博主能帮我看下一个问题吗
    hexo g 后process faile怎么解决
  • 3148c819c76d:太坑了 我卸载git2.5 装上1.9 分分钟hexo d通关 我操操操
  • b68e19dd5f0b:hexo d后没反应是什么回事..
    直接就可以输入下一条命令了
    什么信息都没输出 = =
    e294eafb7674:@眼睛进水 你的deploy没生效,可能是hexo config里面没设置好,比如type后面没有空格啥的
  • 880396393962:执行$ git config --global user.name ""和email

    hexo d后仍显示没有权限是怎么回事呢
    -----
    Permission denied (publickey).
    fatal: Could not read from remote repository.

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

  • 杀死一只程序猿:谢谢,你的建议对我有很大的帮助,2元收好。
    PetrusLaw: @杀死一只程序猿 ^_^
    PetrusLaw: @杀死一只程序猿 😄

本文标题:hexo 部署至Git遇到的坑

本文链接:https://www.haomeiwen.com/subject/jscwcttx.html