Git - Adding Submodule

serhatteker profile image Serhat Teker Originally published at tech.serhatteker.com on ・1 min read

Adding a Submodule to a Git Repository

Adding a submodule to your git repository is actually quite simple. For example, if you are in the working directory of the repository, to add a new submodule:

$ git submodule add <git url>
  • git submodule add – This simply tells Git that we are adding a submodule. This syntax will always remain the same.
  • <git url> – This is the external repository that is to be added as a submodule.

If you want to more control over add feature:

$ git submodule add -b <branch> <git url> <folder/subfolder>
  • <branch> – This fetching different branch from your default branch, e.g master
  • <folder/subfolder> – This add your submodule to another subfolder

to activate the submodule:

$   git submodule init

Posted on by:

serhatteker profile

Serhat Teker


Uomo Universale | Software Engineer | Entrepreneur | builds systems | py:js:go |


markdown guide