Appearance
How to Clone Including Git 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.
Steps to Cloning Repository Including Submodules
Follow the 3 steps coming next to solve the problem:
Cloning project
First, you should git clone the project:
git clone
bash
git clone <remote-repo-url>Initializing a submodule
The second step is setting up the submodule like this:
git init submodule
bash
git submodule initUpdating the submodule
And the final step is updating the submodule:
update git submodule
bash
git submodule updateOr you can shorten the whole process by executing the following:
git submodule and update
bash
git submodule update --initWARNING
If you do not run git submodule update, the submodule folder will stay empty.
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
bash
git clone --recursive git://github.com/foo/example.git
cd exampleWith version 2.13 and later, you can use --recurse-submodules instead of --recursive
git clone recurse submodule
bash
git clone --recurse-submodules -j8 git://github.com/foo/example.git
cd exampleTIP
-j8 is an optional performance optimization available in version 2.8. It fetches up to 8 submodules in parallel.
From version 1.9 to 2.12, use the following:
git clone
bash
git clone --recursive -j8 git://github.com/foo/example.git
cd exampleWith version 1.6.5 and later, you can invoke:
git clone
bash
git clone --recursive git://github.com/foo/example.git
cd exampleFor cloned repositories or older versions, execute:
git clone repositories
bash
git clone git://github.com/foo/example.git
cd example
git submodule update --init --recursiveThe 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 committing snapshots.
The git init and git clone commands are usually confused with each other. The git clone command is dependent on git init and creates a copy of a repository that already exists.