How to Remove Sensitive Data from Your Git History (For Real This Time)
You deleted the file. You committed the deletion. You pushed. You're safe now, right? Nope. That API key, that .env file, that internal config with your database credentials — it's all still there,...

Source: DEV Community
You deleted the file. You committed the deletion. You pushed. You're safe now, right? Nope. That API key, that .env file, that internal config with your database credentials — it's all still there, sitting comfortably in your git history, waiting for anyone with git log and five minutes of curiosity. I learned this the hard way about four years ago when a colleague pinged me to let me know our staging database password was visible in a public repo. I'd removed the file three months earlier. Didn't matter. Git remembers everything. Why Deleting a File Doesn't Actually Delete It Git is a content-addressable filesystem. Every commit is a snapshot of your entire project at that point in time. When you git rm secrets.env and commit, you're creating a new snapshot without that file — but every previous snapshot still has it. Anyone can see it: # Find all commits that touched a specific file, even deleted ones git log --all --full-history -- path/to/secrets.env # Show the contents of that fil