The ProGit book has an interesting section on Removing Object.
It does end with this:
Your history no longer contains a reference to that file.
However, yourreflog
and a new set of refs that Git added when you did thefilter-branch
under.git/refs/original
still do, so you have to remove them and then repack the database. You need to get rid of anything that has a pointer to those old commits before you repack:
$ rm -Rf .git/refs/original
$ rm -Rf .git/logs/
$ git gc
$ git prune --expire
(git prune --expire
is not mandatory but can remove the directory content from the loose objects)
Backup everything before doing those commands, just in case 😉