AuthorEthan
Type折腾🐦
CreatedNov 22, 2025, 16:23:57
UpdatedMar 12, 2026, 21:57:26
Views —
Words193
BLOG
由于作者在本地开发的时候喜欢直接在.env.example文件直接修改隐私信息然后复制成.env文件,导致一不注意就将带有隐私信息的example文件被推送到了github,遂迅速寻找解决办法,如下使用 git-filter-repo来完成操作。
# 使用 pip 安装
pip install git-filter-repo
# 或使用 homebrew (macOS)
brew install git-filter-repo
# 或使用 apt (Ubuntu/Debian)
sudo apt install git-filter-repo
git filter-repo --path .env.example --invert-paths
git log --all --full-history -- .env.example
git remote add origin <your-repo-url>
git push origin --force --all
git push origin --force --tags
之后你可以看到远程repo的记录已经干净
Comments
Discuss this article here.