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

相关推荐
ice___Cpu9 小时前
Git - 1( 14000 字详解 )
大数据·git·elasticsearch
范纹杉想快点毕业1 天前
以项目的方式学QT开发(一)——超详细讲解(120000多字详细讲解,涵盖qt大量知识)逐步更新!
c语言·数据结构·c++·git·qt·链表·github
qq_653644461 天前
如何查看打开的 git bash 窗口是否是管理员权限打开
开发语言·windows·git·bash
tonngw1 天前
【Mac 从 0 到 1 保姆级配置教程 12】- 安装配置万能的编辑器 VSCode 以及常用插件
git·vscode·后端·macos·开源·编辑器·github
橄榄熊1 天前
Git 常用命令详解
git
o(╥﹏╥)2 天前
绑定 SSH key(macos)
开发语言·git·学习·macos
半新半旧2 天前
Git 分支指南
git
qq_464357012 天前
git中忽略文件.gitignore文件的用法
git
程序员阿鹏2 天前
Git的安装和配置(idea中配置Git)
java·开发语言·ide·git·intellij-idea·idea
belldeep3 天前
如何阅读、学习 Git 核心源代码 ?
git·学习·源代码