How to Clone Including Submodules
A problem may occur when the submodule folder stays empty in the process of cloning the parent Git Repository. In this tutorial, we are going to show you several ways of cloning the repository that will solve your problem.
First, you should git clone the project, then set up the submodule and update:
git clone git submodule init git submodule update
Or you can shorten the process by executing the following:
git submodule update --init
But you can use other methods regarding the versions of Git.
Using Git 1.6.5 version or higher, you can execute a single line:
git clone --recursive URL
With version 2.13 and later, you can use --recurse-submodules instead of --recursive
git clone --recurse-submodules -j8 git://github.com/example/example.git cd bar
From version 1.9 to 2.12, use the following:
git clone --recursive -j8 git://github.com/example/example.git cd bar
With version 1.6.5 and later, you can invoke:
git clone --recursive git://github.com/example/example.git cd bar
For cloned repositories or older versions, execute:
git clone git://github.com/example/example.git cd bar git submodule update --init --recursive
The git init and git clone Commands
The git clone creates a clone or copy of an existing repository into a new directory. It is the most commonly used command which allows users to obtain a development copy of an existing central repository.
The git clone initializes a new repository in the team-project folder on the local machine and fills it with the contents of the central repository. Next, you can cd into the project starting modification of files, interaction with other repositories, and commitment of snapshots.
The git init and git clone commands are usually confused with each other. The git clone command is dependant on git init and creates a copy of a repository that already exists.