按特定扩展名从历史记录中删除文件

dwo*_*sch 3 git

我不小心提交了不应该在存储库中的文件。现在我想从历史记录中删除这些文件。它们的共同点是文件扩展名为 *.test。

我尝试应用索引过滤器,但需要特定的文件名。

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

是否可以在一个步骤中对所有文件执行此操作而无需手动指定它们?

dwo*_*sch 6

这几乎令人难以置信,但我的脚本中有一个错字,但我认为我也必须避开星号。

所以这个脚本对我有用

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