删除单个文件

1
git filter-branch --force --index-filter "git rm --cached --ignore-unmatch path/to/your/remove/file" --prune-empty --tag-name-filter cat -- --all

路径前不能有”/“

删除文件夹

git rm后添加-r参数即可

1
git filter-branch --force --index-filter "git rm -r --cached --ignore-unmatch path/to/your/remove/directory" --prune-empty --tag-name-filter cat -- --all

路径前不能有”/“

错误

1
bad revision 'rm'

应使用双引号