I have a repo with several submodules. I want to add some others, and the fastest way for me is to use the .gitmodules
(which in my opinion should clearly allow any kind of submodule management).
However, when editing this file and adding submodules, after a git submodule init
nothing is added (except the submodules that were already present before the modification).
Is there any solution to add a submodule without going through git submodule add
(ie, just by editing the .gitmodules
file and then git submodule update --init
) ?
That is, the following workflow should automatically add the submodule "foo/bar":
Add the following to .gitmodules:
[submodule "foo/bar"]
path = foo/bar
url = https://example.com/foo.git
Run the following command after saving:
git submodule init
git submodule update
Expected result:
submodule 'foo/bar' automatically gets added
it is also updated (the update command)
git submodule add
its simply adding the new entry to the .submodules files, so what you described is correct and it should work for you. this is why after theadd
you have to runinit & update
– Musettagit submodule add
results in the module not being added for me (sadly)... When you think about it, git is able to track thousands of modifications in a lot of files, but totally lost when it comes to 3 added lines in.gitmodules
... – Greaser.git
folder. – MusettaGIT_TRACE=2 git submodule add [email protected]....
– Musetta