Git - Remove All of a Certain Type of File from the Repository

lmat - Reinstate Monica picture lmat - Reinstate Monica · Aug 10, 2016 · Viewed 16.6k times · Source

How do I remove all of a certain type of file from the Repository? I'm using

git filter-branch --index-filter 'git rm -rf --cached **/*.jar'

Either git is not expanding globs, or it isn't expanding ** in the way I'm expecting.

Answer

CodeWizard picture CodeWizard · Aug 10, 2016

You simply have to run this in order to remove all your jars from the index:

git rm -r --cached **/*.jar

Run this command from your root directory of the project and it will clean up and will remove all your file only from the staging area.