Trusted answers to developer questions

How to clone a project that contains Git Submodule

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

Git submodules are a powerful way to use git as an external dependency management tool (this is analogous to creating a soft link on your system). This shot covers what will need to be done if you are cloning a project that has a submodule in it.

When you clone a project with submodules, you will get the directories that contain the submodules by default, but they won’t have any of the files within them yet. There are two ways in which you can get these files.

The first method is a combination of following two commands:

git submodule init
git submodule update

The second method is to pass a --recurse-submodules to the git clone command while cloning the repository:

git clone <respository_url> --recurse-submodule

RELATED TAGS

git
submodule
Did you find this helpful?