In my personal git repo, I have a directory that contains thousands of small images that are no longer needed. Is there a way to delete them from the entire git history? I h
Brandon Thomson asked in a comment to Rainer Blome's solution if this just fixed the gitk view or if the refs will be really gone. A good way to check this is to remember one of the sha1 hashes (or a unique prefix of it) of the old commits and try
$ git ls-tree hash-value
This should show you the content of the repos main folder as it was in this commit. After
$ rm -Rf .git/refs/original
$ rm -Rf .git/logs/
as shown by VonC and removing the refs/original/… lines from .git/info/refs and .git/packed-refs as shown by Rainer Blome, a final
$ git gc --prune=now
made not only the refs, but also the old objects (commits, trees, and blobs) go away. The above shown git ls-tree hash-value proves this.
Another nice command to check this is git count-objects -v (run it before the filter-brach and after the pruning and compare the size).
Note: As I'm not allowed yet to comment on the other answers, I had to write a new one although it mainly combines previous given answers.