惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - Franky
G
Google Developers Blog
罗磊的独立博客
美团技术团队
腾讯CDC
GbyAI
GbyAI
博客园 - 司徒正美
Recent Announcements
Recent Announcements
P
Privacy International News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MongoDB | Blog
MongoDB | Blog
J
Java Code Geeks
IT之家
IT之家
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
I
Intezer
博客园 - 叶小钗
C
Cisco Blogs
Engineering at Meta
Engineering at Meta
Latest news
Latest news
博客园 - 聂微东
Apple Machine Learning Research
Apple Machine Learning Research
Scott Helme
Scott Helme
阮一峰的网络日志
阮一峰的网络日志
Cyberwarzone
Cyberwarzone
Microsoft Azure Blog
Microsoft Azure Blog
S
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
T
Threatpost
人人都是产品经理
人人都是产品经理
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LangChain Blog
爱范儿
爱范儿
博客园 - 三生石上(FineUI控件)
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
Stack Overflow Blog
Stack Overflow Blog
P
Privacy & Cybersecurity Law Blog
博客园 - 【当耐特】
Y
Y Combinator Blog
Last Week in AI
Last Week in AI
D
DataBreaches.Net
量子位
The Hacker News
The Hacker News
C
CERT Recently Published Vulnerability Notes
L
LINUX DO - 最新话题
S
Securelist

Zero の 日常

MacBook M1 Pro 双屏方案 上海电信SDN更换7015TV CNAME与MX记录冲突小记 RHEL 7.9 从 GRUB 引导启动 Hardware upgrade for 2022 Valve Index + HTC Tracker 3.0 开箱记录! 有手就行系列:SlimeVR全身追踪方案 基于goestools与xrit-rx的GK2A气象卫星接收教程 Prometheus实现对IDRAC的SNMP监控 Maven中央仓库项目上传指南 CQ CQ CQ DE BG5ISN PSE K 关于我买不到空气显卡这件事 Mac iTerm2 lrzsz 从零开始的飞机追踪之旅 Protobuf浅解 Prometheus + AlertManager实现告警推送 Prometheus Exporter Prometheus监控系统部署 Nginx负载均衡(加权轮询)
GitHub单个文件脱敏处理
Zero · 2020-12-24 · via Zero の 日常

最近往 github push 代码时不小心将 token 等敏感数据一起给提交到了仓库,如果是单次的话可以选择回退到上一次提交,或者还未 push 到仓库的情况下可以选择 git commit --amend,但是我后续很多次 commits 都未对这个文件进行脱敏处理,这种情况就会比较麻烦。

  • 遍历所有的 commit,删除指定文件,重写历史 commit
1
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch <file path>" --prune-empty --tag-name-filter cat -- --all
  • 本地记录覆盖到 Github (所有 branch 以及所有 tags)
1
2
git push origin --force --all
git push origin --force --tags
  • 强制解除对本地存储库中的所有对象的引用和垃圾收集
1
2
3
git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now

其他文章