How to add Submodules to a Git Project


Article Outline
  1. 1. Working with Submodules in Git
    1. 1.1. Adding a Submodule to an existing repo
Keywords: , ,

This article contains instructions for using submodules in your git repository.

Working with Submodules in Git

Adding a Submodule to an existing repo

  1. Navigate to the root folder of the git repo you want to add the submodule to.

  2. Run the following command to add a submodule in a specified folder of the current repo,

git submodule add https://github.com/githubuser/repo-url folder/

  1. Run git submodule init to initialize the submodule repo within the active repo.

  2. Run git submodule update to download the files from the submodule repo.

  • You should now see the files populated within the submodule folder.
  1. Please Note: Now anytime you or another member of your organization clones a new instance of the project, they will need to run git submodule init && git submodule update to ensure they have the submodule files added to the working project.