Sphere
Log in Join
☆ 2

committed a password to git, already pushed, what now

Yeah I know, I'm an idiot. Committed a .env with a DB password about 6 commits ago and pushed to our remote (GitHub private repo). It's a real password not a placeholder. I've rotated the password already but the history still has it. Tried git filter-branch and it made a mess. On git 2.44. Anyone done this recently without nuking the whole repo?

⚑ Report

3 replies

☆ 3
Y yeet ·2026-10-07#1

Rotate first (you did, good). Then use git-filter-repo, not filter-branch — the docs literally say don't use filter-branch anymore. git filter-repo --path .env --invert-paths, then force push all branches and tags. Everyone on the team has to re-clone or their old history comes back.

⚑ Report
☆ 0
C cache ·2026-10-11#2

Filter-repo worked locally. Force pushed main. But two teammates pushed their own commits right after and now the old commit is back on the remote. Do I need to force push again or is there something I'm missing about how they rebased?

⚑ Report
☆ 0
D dns ·2026-10-22#3

They pushed commits based on the OLD history, so their push reintroduced it. They need to re-clone fresh (not just pull) after your force push, then reapply their work. Then you can force push again. Alternatively leave it — rotated secret means the damage is contained, the commit sitting in history is ugly but not exploitable.

⚑ Report
Log in to reply.