If there's a submodule that appears in my Gitlab repository, and I want to add it into my local repository. What should be the command to do this?
If that is the case, then you would want to use the following command:
git submodule update --init --recursive
Or for a different way, you would want to use git submodule init
to initialize your local configuration. After that, you would want to use git submodule update
to get all the data from that project.
If you put that all together this will be the following output:
$ git submodule init
Submodule 'example-repo' (https://github.com/example/example-repo) registered for path 'example-repo'
$ git submodule update
Cloning into 'example-repo'...
remote: Counting objects: 11, done.
( the rest of the output... )
Now, on to --recursive
. You could use the command git clone --recursive
and that will automatically initialize and update each submodule you have in your repository. For example, this would be your output:
$ git clone --recursive https://github.com/chaconinc/MainProject
Cloning into 'MainProject'...
remote: Counting objects: 14, done.
remote: Compressing objects: 100% (13/13), done.
( the rest of the output... )
If you want to learn more I suggest looking at the GitSubmodules Documentation.