Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove files from history by specific extension

Tags:

git

I have accidently committed files that shouldn't be in the repository. Now I want to remove this files from history. What they have in common is, that they have the file extension *.test.

I tried to apply an index filter but that expects a specific file name.

git filter-branch --force --index-filter 'git rm --chached --ignore-unmatch -r *.test' --prune-empty -- --all

Is it possible to do this for all files in one step without specifying them manually?

like image 882
dwonisch Avatar asked May 31 '15 17:05

dwonisch


1 Answers

It's nearly unbelievable, but I had a typo in my script, but I think I have to escape the asterisk too.

So this script is working for me

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch -r \*.test' --prune-empty -- --all

like image 51
dwonisch Avatar answered Oct 03 '22 19:10

dwonisch