Git 永久删除文件

永久删除 Git 提交的文件,减小 .git 文件夹大小。

这里使用 BFG:https://rtyley.github.io/bfg-repo-cleaner/

# 使用 --mirror(--bare) 参数 clone git repo
git clone --mirror git://example.com/some-big-repo.git

# 删除 100M 以上的文件 
java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git
# 删除 test.sdf 文件 
java -jar bfg.jar --delete-files test.sdf some-big-repo.git
# 删除 _Boot 文件夹,且忽略 HEAD 版本保护
java -jar bfg.jar --delete-folders _Boot --no-blob-protection some-big-repo.git

# 推送到 Git
cd some-big-repo.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push

https://git-scm.com/book/zh/v2/Git-工具-重写历史#核弹级选项:-filter-branch

https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/removing-sensitive-data-from-a-repository

https://www.cnblogs.com/huipengly/p/8424096.html

https://www.cnblogs.com/flying_bat/p/4172435.html

原文地址:https://www.cnblogs.com/jhxxb/p/13792846.html