Git refusing to create/use dir in other submodule's dir

Viewed 2022

I'm trying to update git submodules recursively using git submodule update --recursive --remote --init. The modules structure is:

  • A
    • B
      • C/master
      • C/backend
      • C/frontend

All branches in use in C are orphan with completely separated code...

All repos are private, but I´m the owner.

This is the message I get everytime. (Tried syncing, using git://, updating first without recursion)

Failed to clone 'C/master'. Retry scheduled

error: submodule git dir 'F:/Docs/A/.git/modules/B/modules/C/backend' is inside git dir 'F:/Docs/A/.git/modules/B/modules/C'

fatal: refusing to create/use 'F:/Docs/A/.git/modules/B/modules/C/backend' in another submodule's git dir

Any ideas how to fix this?

1 Answers

Since the repository name and path name were differnt, git add named the submodule by path name, not direcotory name and changing the submodules' name in .gitmodules in repo B fixed this...

Previosly:

[submodule "Folder/master"]
    path = Folder/master
    url = https://github.com/tomkys144/C
    branch = master
[submodule "Folder/backend"]
    path = "Folder/backend
    url = https://github.com/tomkys144/C
    branch = backend
[submodule "Folder/frontend"]
    path = Folder/frontend
    url = https://github.com/tomkys144/C
    branch = frontend

Fixed:

[submodule "C/master"]
    path = Folder/master
    url = https://github.com/tomkys144/C
    branch = master
[submodule "C/backend"]
    path = "Folder/backend
    url = https://github.com/tomkys144/C
    branch = backend
[submodule "C/frontend"]
    path = Folder/frontend
    url = https://github.com/tomkys144/C
    branch = frontend
Related