Revoke or rotate the exposed Stripe secret key and database password first. Removing a file from Git history cannot make a copied credential safe. Update the applications that use the replacement credentials and confirm the old ones no longer work. Review the providers’ access/activity logs for unexpected use.
Then stop tracking the file: add .env to .gitignore and use git rm --cached .env. That command removes it from the next commit while keeping the local file. Commit a safe .env.example containing variable names and dummy values, never working secrets.
Historical cleanup is a separate, coordinated step. Ask the collaborator to pause pushes, preserve legitimate work, and follow GitHub’s current sensitive-data removal procedure. It uses git-filter-repo and rewrites commit identities. Check all affected paths/renames and branches; simply editing the latest commit is insufficient when the secret was pushed earlier.
After any authorised rewrite, collaborators must clean or replace old clones so they do not push the old history back. Copies may remain in forks, caches or other people’s clones. Rotation remains the essential protection even when a repository’s visible history is cleaned.
To prevent recurrence, keep secrets in environment configuration or a secret manager, review staged diffs, and enable appropriate secret scanning/push protection. Do not paste the actual key or password into a public issue while requesting help.
The commands below only stop future tracking; they do not erase historical exposure.
Prepared with AI assistance by Tai. Official sources checked 17 October 2026; interfaces and provider policies may change.
No comments yet.