Hexo博客GitHub备份

我们经常会用github page来部署hexo博客,但是我们hexo的源代码却没有备份。

我们可以在GitHub上建一个私有仓库来备份。

  1. GitHub上建一个private repository,命名为 Hexo-Blog

  2. 本地的 .gitignore 文件修改为:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    .DS_Store
    Thumbs.db
    db.json
    *.log
    node_modules/
    public/
    .deploy*/
    _multiconfig.yml
    themes/*/.git
    themes/*/.github
  3. 进入 themes/butterfly,删除 .git.github 文件夹(否则会被识别为子模块,无法上传)

  4. 初始化git

    1
    2
    git init
    git branch -M main
  5. 关联仓库

    1
    git remote add source git@github.com:zhangxixi2008/Hexo-Blog.git
  6. 全部提交

    1
    2
    3
    4
    5
    6
    # 添加所有源码文件
    git add .
    # 提交备注
    git commit -m "完整备份hexo博客源码"
    # 推送到私有仓库main分支
    git push -u source main
  7. 后续修改后提交

    1
    2
    3
    git add .
    git commit -m "更新:新增xxx文章/修改配置"
    git push source main