0 votes
1 view
in Devops and Agile by (24.1k points)

I have a git repo with a bunch of submodules in it. I want to add a submodule, but when I run git submodule add <[email protected]:...> in the directory, I get the following error message:

You need to run this command from the toplevel of the working tree.

So the question is: How do I add a submodule to the directory?

1 Answer

0 votes
by (41.1k points)

The error means that you need to run the code on the repo so all you need to do is go into the directory where you have your repository and run the following command:

git submodule add <[email protected] ...> module/submodule/

Then this command will help you to add a submodule to a sub-directory.

Refer: https://git-scm.com/docs/git-submodule#Documentation/git-submodule.txt-add-bltbranchgt-f--force--nameltnamegt--referenceltrepositorygt--depthltdepthgt--ltrepositorygtltpathgt

...