Hexo基于Git的备份和恢复方法
备份
这部分没什么好说的,新建一个github仓库gitlab仓库用于存放就行,当然也不是所有文件都需要备份,以下是.gitignore文件内容:
node_modules/
.github/
themes/
_config.landscape.yml
package-lock.json
package.json
db.json
public/
.deploy_git/
恢复
安装软件
Node.js
Git
pandoc
恢复git设置
sh
git config --global user.name "用户名"
git config --global user.email "邮箱"
git config --global core.ignorecase false
git config --global init.defaultBranch main
ssh-keygen -t rsa -C "邮箱"
将新生成的密钥添加至gitlab。
安装Hexo
sh
npm install hexo-cli --location=global
npm install hexo --location=global
恢复VSCode设置
VSCode插件
txt
Insert Date String
恢复文件夹
新建文件夹
初始化hexo
sh
hexo init
安装主题
sh
npm install hexo-theme-fluid --save
更改markdown渲染器
sh
npm uninstall hexo-renderer-marked --save
npm install hexo-renderer-pandoc --save
安装Hexo插件
sh
npm install hexo-deployer-git --save
npm install hexo-generator-sitemap --save
删除文件
sh
rm * -Exclude ./node_modules,*.json -Recurse
同步git仓库
sh
git init --initial-branch=main
git remote add origin git@gitlab.com:GanSong42/writeblog.git
git pull --rebase origin main
git push --set-upstream origin main