使用 git-filter-repo 过滤掉提交中不是给定提交后代的文件列表

Use git-filter-repo to filter out a list of files in commits which are not descendants of a given commit

似乎 git filter-branch 已被弃用,应改用 git-filter-repo。我正在使用 git filter-branch --index-filter 从提交中删除不是给定提交后代的文件列表。这样做就像

git filter-branch --index-filter 'git merge-base --is-ancestor aaaaaaaa $GIT_COMMIT ; if [ $? -eq 1 ] ; then git rm --cached --ignore-unmatch a.txt b.txt c.txt ; fi' HEAD

因此 a.txtb.txtc.txt 从任何不是 aaaaaaaa 的后代的提交中删除。有什么方法可以用 git-filter-repo 实现吗?

使用 git filter-branch 的好处,使用 git filter-repo 的好处。我怀疑是否有可能使 filter-repo 完全按照您的要求进行操作,或者至少不太好。

我建议直接忽略针对 git filter-branch 的大部分批评,尤其是 filter-repo 自述文件中的批评,令人遗憾的是言过其实了。将 export FILTER_BRANCH_SQUELCH_WARNING=1 放入 ~/.bashrc 并完成它。