git filter-branch 从我的存储库中删除所有子模块

Hau*_*and 7 git github revision-history git-rewrite-history

你好,我已经成功重写了历史记录,并获得了我想要提取的 5 个文件夹git filter-branch -f --prune-empty --tree-filter 'rm -rf <all unwanted dirs>',并保留了所有 git 历史记录。

唯一剩下的问题是子模块,我仍然有提交

Subproject commit <hash>

我想从我的 git 历史记录中完全删除所有这些子模块提交,我该如何实现这一点?

ser*_*son 2

我已经做到了

git filter-branch -f --prune-empty --tree-filter '
    git submodule deinit -f .
    git rm -rf lib && rm -rf lib
    find . -name .gitmodules -delete' HEAD
Run Code Online (Sandbox Code Playgroud)

假设我的所有子模块都位于lib目录中