Remove big (.zip) files from git history
I accidentally commit a few .zip files and then revert and delete the .zip files. But when I am trying to push the codes to GitHub then getting a large file error. Because those files’ history is still in the git commit history. After searching few days, I get and figure-out this solution.
Note: there may be other solutions that will efficient for you. But for me, this has worked like a hot knife on the butter because my repository was not too big. So, if you have a huge repository then you can try BFG cli.
- Please take a backup of your repository or files
- Now run the below command
git filter-branch –prune-empty –index-filter ‘git rm -rf –cached –ignore-unmatch BIG_FILE‘ –tag-name-filter cat — –all
Replace the BIG_FILE with your file name, in my case I changed it to *.zip (as I forgot the file name and wanted to remove all .zip file history)
To know more, you can check this article: Finding and Purging Big Files From Git History
If this article helps you then let me know in the comment. And you can share this too.
Happy committing! Be healthy and happy!