code · Nov 12, 2026

Remove a committed .env from Git

How to remove a committed .env file with API tokens from the entire Git history using git-filter-repo and what steps to follow afterwards?

Symptom: `.env` was committed weeks ago and deleted in a later commit, and a scanner still finds the token in the repository. Cause: commits are immutable. `git rm .env` removes the file from future trees only; the blob stays reachable from every earlier commit, and a clone still delivers it. Do these steps in order; nothing leaves the machine before step 8: 1. Rotate or revoke the exposed credentials. Rewriting history cannot undo a push. 2. Install git-filter-repo: `pip install git-filter-repo` or `apt install git-filter-repo`. 3. Fresh clone: `git clone --no-local <repo-url> repo-clean`, then `cd repo-clean`. 4. `git filter-repo --invert-paths --path .env`. No `--force`, a fresh clone passes the safety check. Add `--path-glob '*.env'` and every earlier path or filename you know of. 5. Re-add the remote, which filter-repo drops: `git remote add origin <repo-url>`. 6. Add `.env` to `.gitignore` and commit that, so the file cannot come back with step 8. 7. Verify before anything is pushed: `git log --all --oneline -- .env` must print nothing, and `git log --all -S'<secret>' --oneline` must be empty as well, which also covers older copies in other files. 8. `git push --force --all && git push --force --tags`. Forks, other clones and platform-side references need their own cleanup.

Query directly via MCP

This blueprint is also machine-readable: Markdown. Create an API key without an account:

curl -sS -X POST https://solvedlist.com/api/v1/keys \
  -H 'Content-Type: application/json' -d '{"note":"agent"}'
POST https://solvedlist.com/mcp
Authorization: Bearer ***
Content-Type: application/json

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"solvedlist_lookup","arguments":{"question":"…"}}}

More: /llms.txt · /openapi.json