35.4.3 暂存区过滤器

树过滤器因为要将每个提交检出,因此非常费时,而参数—index-filter给出的暂存区过滤器则没有这个缺点。如果将之前使用树过滤器删除文件的操作换成用暂存区过滤器来实现,将会运行得更快。


$git filter-branch—index-filter'

git rm—cached—ignore-unmatch filename

'——all


其中参数—ignore-unmatch让git rm命令不至于因为暂存区中不存在filename文件而失败。