问题

为了方便维护 gitpages 项目,我们可以把整个 gitpages 项目作为一个git项目管理,而 Hexo 主题一般也都是用 git 项目进行管理,我们从远程 git 仓库 clone 一份下来,放到 themes/ 文件夹下。每个主题是一个包含 .git/ 的子项目仓库。所以在 push 主项目的时候不会上传子项目。

解决

采用用 fork + subtree 的方案进行解决,这里以 miho theme 为例。

首先要 fork 主题,然后拉取到本地做修改,修改好后push到远程仓库。

然后用 git subtree 把 themes/miho/ 当做子项目来统一管理。subtree 的用法可以参考其他相关教程。

1. 删除现有的主题

1
2
3
4
rm -rf themes/miho
git add -A
git commit -m "delete miho"
git push origin master

2. 绑定子项目

1
2
git remote add -f miho https://github.com/WongMinHo/hexo-theme-miho.git
git subtree add --prefix=themes/miho miho master --squash

3. 更新子项目

1
2
git fetch miho master
git subtree pull --prefix=themes/miho miho master --squash

4. 把项目push到远程仓库

1
git push origin master

现在远程仓库的themes/miho/就有内容了,并且跟子项目的远程仓库可以保持更新,在主项目中修改也可以push到子项目的远程。

参考

  1. Hexo主题同步

最后更新: 2019年04月19日 21:37

原始链接: http://andersjing.com/2018/06/30/hexo-theme/

× 请打赏~
打赏二维码