Reputation: 4201
I recently added a file to my .gitignore, but my repository contains previous commits that include that file. Commits from here on out no longer track the ignored file thanks to using
git rm --cached config/secrets.yml
Is there a quick git command that will go through all of my previous commits and remove that file from showing in my commit history?
Upvotes: 0
Views: 560
Reputation: 1618
It’s not easy. You have to go through each commit and remove that file. And keep in mind that will modify the history, be careful if you are collaborating with others.
Here is a guide from GitHub on how to remove sensitive data: https://help.github.com/articles/remove-sensitive-data/
The resulting command should be:
git filter-branch --force --index-filter \
'git rm --cached --ignore-unmatch config/secrets.yml' \
--prune-empty --tag-name-filter cat -- --all
Upvotes: 1