hexo删除历史大文件
在git hexo仓库中有一个超过100MB的文件,并且你不小心Commit后,会出现如下报错
remote: error: Trace: 0224239f8e73847812271f660f9977951bd9387c22167deff41b61998441cf36
remote: error: See https://gh.io/lfs for more information.
remote: error: File mymusic/XXX.mp3 is 169.72 MB; this exceeds GitHub’s file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To github.com:bigworldxld/bigworldxld.github.io.git
! [remote rejected] HEAD -> master (pre-receive hook declined)
error: failed to push some refs to ‘github.com:bigworldxld/bigworldxld.github.io.git’
当git仓库中添加&删除了大文件后, 历史记录仍然有该文件, 超过100MB的限制,而无法提交,寻找了一下这个文件,发现已经被删除,但是commit中还是有此文件的提交记录。
安装 git filter-repo
使用pip安装git filter-repo去消除历史文件
pip install git-filter-repo
执行清理XXX文件
若出现执行git命令报错:fatal: not a git repository (or any of the parent directories): .git
问题分析
没有初始化git本地版本管理仓库,在打开文件的子目录层级中不包含.git文件,所以无法执行git命令。解决方案
跳到包含git.sh的文件目录下,执行git初始化 ,进行初始化
git init
执行清理shared/log/cron.log文件
git filter-repo --invert-paths --path "shared/log/cron.log" --force
git gc:
git gc --prune=now
删除.deploy_git文件
重新提交
hexo clean
hexo g
hexo d
博客备份
hexo的封面图片和音乐信息需要提前备份好,避免清数据没有了!!!
在git push推送时出现remote: fatal: pack exceeds maximum allowed size问题,经过排查,是由于出现大文件,解决方法:把没用的大文件删除,然后进行分批次上传文件并进行提交即可。
remote: fatal: pack exceeds maximum allowed size
最近使用git pull代码时总遇到这个问题,记录下解决办法,仅供参考!这个问题主要还是因为git add中有大文件存在,最直接的办法是用git lfs上传。
最近使用git pull代码时总遇到这个问题,记录下解决办法,仅供参考!
这个问题主要还是因为git add中有大文件存在,最直接的办法是用git lfs上传。
1.安装git-lfs
sudo apt-get install git
git lfs install
- 将需要上传的文件加入git lfs track,取消用git lfs untrack
# 加入git lfs track,会在执行文件夹下产生.gitattributes
git lfs track "*.pth"
git add .gitattributes
git commit -m "add lfs track file" .gitattributes
# 取消git lfs untrack
git lfs untrack ".pth"
Git LFS 其他命令
显示当前被 lfs 追踪的文件列表
git lfs ls-files
查看现有的文件追踪模式
git lfs track
查看当前 git lfs 版本
git lfs version
取消 LFS 的全局配置
git lfs uninstall
博客备份恢复
下载原始数据包
输入命令git clone -b main url (目前Git最新版本默认都是main,老版本是master),这里也可以选择你要拉取的分支到本地。
1.进入hexo根目录
2.直接把箭头指向的.deploy_git
和public
直接删除!
先依次执行:
hexo clean
hexo g
hexo d
在将public下需要的图片和音乐文件上传
常见hexo错误
hexo Template render error: (unknown path) Error: expected end of comment, got end of file
FATAL Something’s wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Template render error: (unknown path)
Error: expected end of comment, got end of file
某一篇博客中可能存在”’{ #“字符串,去掉它,或者去掉”#”.