Completely remove a file from whole git repository

Github provide a useful help page on removing files like this. There are also other questions on StackOverflow which cover this

  • Completely remove unwanted file from Git repository history
  • How can I completely remove a file from a git repository?

See also this section of the Pro Git book, an example given there:

To remove a file named passwords.txt from your entire history, you can
use the –tree-filter option to filter-branch:

$ git filter-branch --tree-filter 'rm -f passwords.txt' HEAD
Rewrite 6b9b3cf04e7c5686a9cb838c3f36a8cb6a0fc2bd (21/21)
Ref 'refs/heads/master' was rewritten

After the cleanup, you could also try a git gc to further compress and clean up for repository.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)