1. 准备条件

安装了Node.js,Git,Hexo环境,并完成Github与本地Hexo的对接。

2. 在其中一个终端操作

在利用Github+Hexo搭建自己的博客时,新建了一个Hexo的文件夹,并进行相关的配置。

步骤:

1
2
3
4
5
6
7
git init //初始化本地仓库
git add source //添加必要的文件
git commit -m "Blog Source Hexo"
git branch hexo //新建hexo分支
git checkout hexo //切换到hexo分支
git remote add origin git@github.com:yourname/yourname.github.io.git //将本地与Github项目对接
git push origin hexo //push到Github项目的hexo分支上

3. 另一终端完成clone和push更新

在另一终端更新博客,只需要将Github的hexo分支clone下来,进行初次的相关配置。

步骤:

1
2
3
4
5
6
7
8
git clone -b hexo git@github.com:yourname/yourname.github.io.git
cd yourname.github.io
npm install
hexo new post "new blog name"
git add source
git commit -m "XX"
git push origin hexo
hexo d -g

4. 不同终端间愉快地玩耍

在不同的终端已经做完配置,就可以愉快的分享自己更新的博客。

步骤:

1
2
3
4
5
git pull origin hexo
hexo new post "new blog name"
git add source
git commit -m "XX"
hexo d -g