Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k 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 (50.2k 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 <git@github ...> 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

Browse Categories

...