I have a top project, with about 10 submodules, and some nested submodules.
./top-project/
./top-project/module-a
./top-project/module-b
...
Some submodules have a classic url, like url = git:software/module-a, other have an url relative remote top-project like url = ../module-b. top-project url is url = git:software/top-project.
I want to create a worktree copy of top-project, AND all its submodules.
git worktree add -f ../top-project-v2
But I can't find a way making the submodules pointing to their original path. I would like that top-project-v2/module-a git pointing to top-project/module-a, and not cloning a brand new module-a.
If I do cd top-project-v2; git submodule upate --init --recursive, the command succeeds but submodules are not linked to top-project submodules.
If I do git checkout --recurse-submodules origin/v2, I get an error:
git checkout --recurse-submodules origin/v2
fatal: not a git repository: ../../top-project/.git/worktrees/top-project-v2/modules/module-a
fatal: could not reset submodule index
Is there any way to do so?