hexo 部署至Git遇到的坑

查找資料的時候發現了next這個博客主題,next!很是的漂亮,順手查看了hexo的相關部署。html

Hexo官方介紹

Hexo 是一個快速、簡潔且高效的博客框架。Hexo 使用 Markdown(或其餘渲染引擎)解析文章,在幾秒內,便可利用靚麗的主題生成靜態網頁。
官網 https://hexo.io/zh-cn/docs/index.htmlnode

Hexo博客創建

簡潔高效,如同官網的介紹。安裝過程很是簡單,官網有很是詳細的文檔,安裝文檔;而且仍是中文的哦!git

部署至github

安裝完成後須要部署至github,根據官網的介紹,首先進行配置
hexo-git配置github

安裝hexo-delopyer-git

安裝hexo關於git管理組件:hexo-delopyer-git,照着作便可bash

修改配置文件

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

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管理庫的環境變量便可;hexo

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

設置完畢後強制更新環境變量,或者重啓電腦~app

讀取不到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.pngssh

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/

相關文章
相關標籤/搜索