Well it happens to me all the time. While developing, I add a config file with some sensitive data somewhere in my repository, forget to add it to my .gitignore and accidentally commit it. Then, after another 5 commits, I notice my flaw and then have to somehow purge the file from my repo.
Then the search begins and I spend another 10 minutes finding out how to remove that file. So this post is more of a reminder for myself. Future Jan, next time you forget to ignore that .ftpconfig file with the password for your FTP server, just run this command to purge it from each and every commit:
git filter-branch --index-filter \ 'git rm --cached --ignore-unmatch <file>'
Yes, thats a two-liner. Just copy paste the code in your console, change the filename and execute it. Don’t forget to add the file to your .gitignore. You are welcome, you from the past.✌️