How to remove file from Git history?
git, github
Solution
I have found this answer and it helped:
git filter-branch --index-filter 'git rm -rf --cached --ignore-unmatch path_to_file' HEAD
Problem
Some time ago I added info(files) that must be private. Removing from the project is not problem, but I also need to remove it from `git` history. I use Git and Github (private account). Note: On this thread something similar is shown, but here is an old file that was added to a feature branch, that branch merged to a development branch and finally merged to master, since this, a lot of changes was done. So it's not the same and what is needed is to change the history, and hide that files for privacy.
Related problems
- How can I remove/delete a large file from the commit history in the Git repository?
- How do I 'overwrite', rather than 'merge', a branch on another branch in Git?
- How do you fix a bad merge, and replay your good commits onto a fixed merge?
- `git filter-repo` commands output nothing on Windows
- What is the difference between "--tree-filter" and "--index-filter" in the "git filter-branch"?
- Remove commit for good