'Using git submodule update fails but git clone directly works well

There are submodules in the project and I use following command to clone submodules recursively.

$ Git clone --recurse-submodules ssh://[email protected]:29418/ipg-sh/mcf/mcf_fw.git
Cloning into 'C:/Users/peterwei/mcf_fw/modules/bsp/hal/intel'...
Welcome to Intel Hardened OS
remote: Enumerating objects: 81, done.
remote: Counting objects: 100% (81/81), done.
remote: Compressing objects: 100% (69/69), done. 
remote: Total 859 (delta 28), reused 34 (delta 6), pack-reused 778
Receiving objects: 100% (859/859), 231.22 KiB | 432.00 KiB/s, done.
Resolving deltas: 100% (267/267), done.

The result is that the folder only contains .git file, as below.

enter image description here

However, if I cd into the folder 'C:/Users/peterwei/mcf_fw/modules/bsp/hal/intel' and do clone with following command

$ git clone ssh://[email protected]:29418/ipg-sh/modules/bsp/hal_intel.git
Cloning into 'hal_intel'...
Welcome to Intel Hardened OS
remote: Enumerating objects: 81, done.
remote: Counting objects: 100% (81/81), done.
remote: Compressing objects: 100% (69/69), done.
remote: Total 859 (delta 28), reused 34 (delta 6), pack-reused 778
Receiving objects: 100% (859/859), 231.22 KiB | 457.00 KiB/s, done.
Resolving deltas: 100% (267/267), done.

I can download all files successfully.

enter image description here

What's the difference and why the git submodule method doesn't work well?

git


Solution 1:[1]

The difference is: you have created a nested Git repository inside a subfolder you your main repository. That nested repo content will be ignored by the parent repository.

Try a git submodule update --init inside your main repository (after having removed any nested repo manually cloned)

Check what URL is registered in your main repo .gitmodules file.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 VonC