1. 下载 下载BFG Repo-Cleaner工具,如 bfg-1.14.0.jar。
  2. 把敏感信息在当前最新版本里都删除。
  3. 使用mirror标志克隆一个裸仓库(普通文件将处于不可见):git clone --mirror git@git.woa.com:aaa/myproject myproject_rmhistory
  4. 生成一个 rule 文件,如 rule.txt:testpass。每一行一个敏感词。
  5. java -jar bfg-1.14.0.jar --replace-text rule.txt myproject_rmhistory
  6. cd myproject_rmhistory
  7. git reflog expire --expire=now --all && git gc --prune=now --aggressive
  8. 关闭对 master 的写保护:git push -f