github+hexo多终端同步

思路

操作思路很简单,就是把站点的东西全部存放在github项目中的hexo分支中,A、B电脑只要维护项目的hexo分支就行。

初始化hexo分支(A电脑)

1
2
3
4
5
6
7
git init //初始化本地仓库
git add . //添加所有的文件(hexo所有的文件)
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分支上

使用hexo分支(B电脑)

1
2
3
4
5
6
7
8
git clone -b hexo git@github.com:yourname/yourname.github.io.git //将Github中hexo分支clone到本地
cd yourname.github.io //切换到刚刚clone的文件夹内
npm install //安装必要的所需组件,不用再init
hexo new post "test" //新建一个.md文件,并编辑完成自己的博客内容
git add source //添加文字
git commit -m "测试"
git push origin hexo //更新分支
hexo d -g //同步博客到Github中的master

维护hexo分支(A、B电脑)

1
2
3
4
5
6
git pull origin hexo //先pull完成本地与远端的融合
hexo new post " new blog name"
git add source
git commit -m "XX"
git push origin hexo
hexo d -g
Highter wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
坚持原创技术分享,您的支持将鼓励我继续创作!