0

I have a project X which already has submodules A, B and C. Now I want to add submodule D but it also contains its own submodule A. Is there any way to prevent having 2 As in the whole tree? If someone clones my main project (recursively) I want it to contain A, B, C and D without its own A.

this question is similar however the solution (--depth) limits amount of downloaded history while I want to limit "submodule recursion depth".

Xeverous
  • 973
  • 1
  • 12
  • 25
  • 1
    https://stackoverflow.com/q/1419498/7976758, https://stackoverflow.com/a/4116331/7976758 Found in https://stackoverflow.com/search?q=%5Bgit-submodules%5D+duplicate – phd Oct 29 '20 at 13:55
  • I like the first one, but I'm not sure how to remove a submodule - should I create `A'` by cloning it, removing its own submodules and make a commit in `A` or `Core`? Is that how it works? – Xeverous Oct 29 '20 at 14:07
  • I'd first try symlinks — after removing duplicate submodules worktrees — in hope there would be no changes visible to git so no commit required. – phd Oct 29 '20 at 14:37
  • Symlinks do not work. The `git new-workdir` script wants to use actual `ln -s` command, which will not work on Windows clones, even under Git Bash (which implements `ln -s` as `cp`). The second option however - seems completely broken - git goes mad when it sees 2 different submodules with same origins, it behaves like code with data races - there is only 1 instance of the duplicated repo (in one of possible places) but this place is different depending how did you clone/fetch/work-on root project. – Xeverous Oct 29 '20 at 18:46

0 Answers0