彻底删除git中的某个文件(包括历史提交记录)

bash 复制代码
# 加入要删除example.txt
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch example.txt' --prune-empty --tag-name-filter cat -- --all

官网https://git-scm.com/docs/git-filter-branch已经不建议用git filter-branch,而建议用 git filter-repo。

另外还有个工具叫bfg(beg-repo-cleaner)是一个用于清理Git仓库的开源工具。但是要用到java。

另外贴一个github中的文章:Removing sensitive data from a repository

相关推荐
卡布奇诺-海晨37 分钟前
2025版本的idea解决Git冲突
java·git·intellij-idea
好好沉淀7 小时前
ide进去git突然报Cannot identify version of git executable: no response的错误
git
宇宙超级无敌霸王龙捏11 小时前
Git 分支完整操作指南
git
学编程的小鬼14 小时前
git 中常用的命令
git
小黄酥15 小时前
Sourcetree克隆/获取gitee工程,Git获取SSH密钥
git·gitee·github
小Lu的开源日常16 小时前
踩坑日记:为什么 .gitignore 不起作用了
git·代码规范·trae
Gazer_S20 小时前
【Git 子模块冲突解析】
git
她说..20 小时前
通过git拉取前端项目
java·前端·git·vscode·拉取代码
freedom_1024_20 小时前
解决GitHub大文件推送错误:彻底清理PDB文件并配置.gitignore
git·github
未来的JAVA高级开发工程师20 小时前
Git--
git