Git submodules in .gitmodules not initialized
Asked Answered
E

2

5

https://github.com/Uni-/shBrushesCollection

I created a GitHub repository and made a .gitmodules file directly from GitHub's web source editor. When I then cloned the repo, I noticed the submodules in .gitmodules were not being initialized.

I think I tried almost all commands possible, including update, init, update --init and so on. Is there a way to use current .gitmodules file, not submodules add?

Elvieelvin answered 3/7, 2013 at 7:16 Comment(0)
D
8

Writing a submodule isn't enough.

You should rather use git submodule add: that will update your .gitmodules file and create a special entry in the index (where you want that submodule to be loaded).

Then, when you push that to your upstream repo on GitHub, the project page will display those special entries as a green folder.

green folder

Diageotropism answered 3/7, 2013 at 7:25 Comment(2)
Thanks. So it's because there is no gitlink object... Then why does .gitmodules exist, while .git/config is what really works?Elvieelvin
@Uni- because .git/config is purely a local configuration which isn't pushed/pulled. .gitmodules is a file which declares those submodules, part of the repo, pushed to other repos, and allowing any local repo cloning that file to build back its local .git/config with said submodules.Diageotropism
B
0

.gitmodules exists,
✓ submodule directory exists,
✗ but no files or sub-directories are in the submodule directory, ...

git submodule update --init is required, once, for this remote clone.

Brass answered 6/12, 2023 at 23:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.