You accidentally committed `.env` with the production AWS keys and pushed. Rotating the key is step zero — but you also need it gone from history.
Rotate the key first. `git rm --cached` stops tracking the file from here on; scrubbing it out of every past commit needs git-filter-repo or BFG, which run outside this browser.
Expert · 7 steps · +900 XP
This scenario walks through 7 steps, in order:
Try the terminal first — you learn more by doing. When you want to check yourself, here is the command for each step.
git ls-filesgit rm --cached .envecho ".env" >> .gitignoregit add .gitignoregit commit -m "chore: stop tracking .env"git push --force-with-lease origin maingit gc --prune=now --aggressiveRotate first — that is the only step that actually protects you. Untracking `.env` and adding it to `.gitignore` stops the next leak, but the old commits still hold the key until you rewrite history with git-filter-repo or BFG. Anything pushed to a public remote should be considered compromised forever.