彻底删除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

相关推荐
ControlRookie10 小时前
SyncBridge:一个 CODESYS 工程与 AI 之间工程师级的同步工具
git·ai编程·codesys·工业软件·controlrookie
鬼手点金19 小时前
opencode-性能优化建议
java·人工智能·git·自动化·nanogpt
网络毒刘21 小时前
开源 Aider 工作流实战:Git 提交驱动的 AI 结对,与 Cursor 何时互补
git·ai编程·cursor·aider
HRTOS1 天前
HRTOS 4.0 将长期维护:为什么版本号不再频繁变化
经验分享·git·单片机·51单片机
驭渊的小故事2 天前
linux 基础命令 + git 仓库创建和配置命令
linux·git
行者-全栈开发2 天前
华为云码道 CodeArts 实测:让 AI 用 Rust 写一个 Git 仓库健康度体检台「仓衡」
git·rust·tauri·桌面应用·ai 编程·华为云码道·codearts 代码智能体
挖掘狂人4 天前
Git 从 0 到 1:用一个小项目走完 add / commit / reset / merge / rebase / push
git·后端·github
codigger4 天前
Git 三区域模型:把 add、commit、reset、merge 一次讲透
git·github·编程·编程语言
水饺编程4 天前
第1章:开发环境搭建,在 Windows 中安装 Git
linux·c语言·汇编·git·ubuntu
idanzk4 天前
Git 推送 GitHub 报 SSL_READ /src refspec main 不匹配 完整踩坑记录
git·github·ssl