Pick and choose submodules
Is there a way to pick and choose submodules? I have a .gitmodules file that has two submodules , but I only want to keep one of them.
There is no scheme tailored to do this currently. You can specify --path (perhaps together with --invert-paths) to pick paths to keep or remove, which would remove the actual commits from the submodule, but that wouldn't clean up the .gitmodules file.
However, if you combined that with the lint-history contrib script, you could probably write a simple script that lint-history would call that could alter the .gitmodules file to match your preferences. It'd basically make it into a two step filtering process:
git filter-repo --path unwanted-submodule --invert-paths
contrib/filter-repo-demos/lint-history --relevant 'return filename == .gitmodules' YOUR_SCRIPT_NAME
The second command would repeatedly call
YOUR_SCRIPT_NAME .gitmodules
in some special directory, with different versions of .gitmodules from history, and your script would be responsible for editing that file in place. Whatever changes you made to it would then be recorded in history for the commits that modified the .gitmodules file.
Does that help?