💡 参考文章见Ref,感谢提供思路!
🗺️当前这篇博文地址:https://myoontyee.github.io/article/1b2e5417.html
⚠️警告:博客文章禁止一切形式的非授权非法转载!
⚠️Attention: All forms of unauthorized illegal reposts are prohibited !

创建时间:2023年3月17日10:38:41
最新更新:2023年3月17日22:44:00


Problem Description:How to Clear Commits in GitHub+Hexo Code Warehouse to Avoid Information Leakage?

核心思路


  • 最终实现效果

改配置

  • 首先在Windows下的bash内进入Blog代码所在的代码仓
  • 首先修改代码仓的.git文件夹,然后在bash内进行以下操作
    • 打开.git/config,将url设置修改为对应的代码仓代码
    • 然后进入bash内进行操作,注意操作完需将url调整回来

清空commits与强制推送

  • 新建空白分支
1
git checkout --orphan latest_branch
  • 添加所有文件
1
git add -A
  • 提交
1
git commit -am "."
  • 强制删除旧分支,此处用的分支是master
1
git branch -D master
  • 将当前分支重命名为master
1
git branch -m master
  • 强制推送到远程仓库
1
git push -f origin master
  • 最终实现效果

网页部署

  • 为了确保网页部署,可以在bash内进行如下指令
1
2
3
hexo clean
hexo g
hexo d

方法2

  • 删除Blog代码目录下.deploy_git文件夹
  • 在bash内输入如下指令
1
2
3
hexo clean
hexo g
hexo d

Ref