Hexo博客开发之——theme主题备份上传失败

一 现象

Hexo升级时,theme主题上传到GitHub时,只有主题名,主题文件夹下并没有主题对应文件(主题文件备份失败)

<!--more-->

二 原因

这是因为用到了 git 的子模块(git submodule)功能(你在你的 git 项目里 clone 的别人的项目)。

在你的主项目的 git 库里,子模块只是一个 HEAD 指针,指向子模块的 commit。

这个功能的意义:

  • 在这里,如果你需要修改 next 主题(可能需要很多文档),又想保证能够随时更新最新版本,其实用子模块功能是很方便的

  • 只需要 clone 下来新建一个 branch,用来自己用,每次官方更新 pull 到另一个分支,merge 一下就行。

  • 相当于把一个大项目分成多个小项目,尽可能减少项目之间的关联,方便调试和修改。

  • 这里我偷懒直接将子模块删除,将整个仓库进行备份了

三 修改过程

3.1 themes目录下的文件结构

next-v7.1.1
next-v7.8.0

3.2 移除没有上传的next主题

git rm --cached themes/next-v7.8.0

 

3.3 git status—查看移除主题后的状态

On branch hexo
Your branch is up-to-date with 'origin/hexo'.
​
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
​
        deleted:    themes/next-v7.8.0
​
Untracked files:
  (use "git add <file>..." to include in what will be committed)
​
        themes/next-v7.8.0/

3.4 git add themes/next-v7.8.0/ (重新提交主题文件夹next-v7.8.0)

3.5 git status —查看提交主题后的状态

On branch hexo
Your branch is up-to-date with 'origin/hexo'.
​
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
​
        deleted:    themes/next-v7.8.0
        new file:   themes/next-v7.8.0/.editorconfig
        new file:   themes/next-v7.8.0/.eslintrc.json
        new file:   themes/next-v7.8.0/.gitattributes
        new file:   themes/next-v7.8.0/.github/CODE_OF_CONDUCT.md
        new file:   themes/next-v7.8.0/.github/CONTRIBUTING.md
        new file:   themes/next-v7.8.0/.github/ISSUE_TEMPLATE/bug-report.md
        new file:   themes/next-v7.8.0/.github/ISSUE_TEMPLATE/feature-request.md
        new file:   themes/next-v7.8.0/.github/ISSUE_TEMPLATE/other.md
        new file:   themes/next-v7.8.0/.github/ISSUE_TEMPLATE/question.md

3.6 git commit -m “备份next-v7.8.0主题” (提交)

3.7 git push origin hexo(推送到GitHub备份到hexo分支)

 

四 参考

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值