git filter-branch
git filter-branch
# Rewrite branches
$ git filter-branch
$ git filter-branch [--setup <command>] [--subdirectory-filter <directory>]
[--env-filter <command>] [--tree-filter <command>]
[--index-filter <command>] [--parent-filter <command>]
[--msg-filter <command>] [--commit-filter <command>]
[--tag-name-filter <command>] [--prune-empty]
[--original <namespace>] [-d <directory>] [-f | --force]
[--state-branch <branch>] [--] [<rev-list options>…]
https://git-scm.com/docs/git-filter-branch
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
demo
# clone the repository to your local computer.
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
# Navigate into the repository's working directory.
$ cd YOUR-REPOSITORY
# filter & remove
$ git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA" \
--prune-empty --tag-name-filter cat -- --all
$ echo "YOUR-FILE-WITH-SENSITIVE-DATA" >> .gitignore
$ git add .gitignore
$ git commit -m "Add YOUR-FILE-WITH-SENSITIVE-DATA to .gitignore"
git in action
https://github.com/xgqfrms/xgqfrms/blob/gh-pages/tools/WebStrom-2016.2.4.md
$ git clone https://github.com/xgqfrms/xgqfrms
# git checkout gh-pages
$ cd github/xgqfrms
$ git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch tools/WebStrom-2016.2.4.md" \
--prune-empty --tag-name-filter cat -- --all
# what's `\` & `""` means in git cli???
$ git filter-branch --force --index-filter "git rm --cached --ignore-unmatch tools/WebStrom-2016.2.4.md" --prune-empty --tag-name-filter cat -- --all
$ echo "tools/WebStrom-2016.2.4.md" >> .gitignore
$ git add .gitignore
$ git commit -m "Add YOUR-FILE-WITH-SENSITIVE-DATA to .gitignore"
testing remove-git-commit-history
https://github.com/xgqfrms/xgqfrms/remove-git-commit-history
$ git clone https://github.com/xgqfrms/remove-git-commit-history
$ cd github/remove-git-commit-history
$ git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch tools/WebStrom-2016.2.4.md" \
--prune-empty --tag-name-filter cat -- --all
GitHub SSH key
.po
translate
https://raw.githubusercontent.com/jnavila/git-manpages-l10n/master/po/documentation.zh_HANS-CN.po
refs
https://docs.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository
https://docs.github.com/cn/github/authenticating-to-github/removing-sensitive-data-from-a-repository
©xgqfrms 2012-2025
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/13338946.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
2019-07-19 Sentry & report errors & error tracking
2019-07-19 serverless & front end
2018-07-19 ES6 Map & WeakMap & ES6 Set & WeakSet
2016-07-19 HTML5 应用程序缓存,(Application Cache),CACHE MANIFEST, manifest 文件,
2016-07-19 JavaScript 注释规范
2016-07-19 程序员面试 技术题汇总 All In One
2016-07-19 如何将自己的域名绑定到 GitHub Pages 详细教程 All In One