清洗Git历史 SMTP 明文授权码(filter-repo)清洗Git历史 SMTP 明文授权码(filter-repo)注意:先备份仓库,多人公共分支不要随意重写历史,清洗后重置授权码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 # 方案A:git-filter-repo 清洗历史 SMTP 授权码 # 前置:先备份整个仓库;清洗后务必重置SMTP授权码 # 警告:已推送多人公共分支风险极高 # 下载部署脚本 curl -o git-filter-repo https://raw.githubusercontent.com/newren/git-filter-repo/main/git-filter-repo chmod +x git-filter-repo sudo mv git-filter-repo /usr/local/bin/ # 验证 git filter-repo --version # 写入替换规则 cat > replace.txt <<'EOF' regex:SMTP_PASS=".*"==>SMTP_PASS="" EOF # 执行清洗 git filter-repo --replace-text replace.txt --force # 校验残留 git log -p | grep 'SMTP_PASS="' # 推送(按需取消注释) # git remote -v # git push --force-with-lease --all origin # git push --force-with-lease --tags origin参考链接https://www.doubao.com/thread/xZwqqpn0kwaByB4vC