In our last post, we seen how to create a remote repository in github which actually uses git submodules to have one git directory inside another git directory. In our last post we created the repository at  https://github.com/lynxbee/understanding-git-submodules , now lets try to clone the same as, $ git clone https://github.com/lynxbee/understanding-git-submodules $ cd understanding-git-submodules/ $ tree . ├── README.superproject ├── submodule_one └── submodule_two 2 directories, 1 file As we can see with tree command, git clone of superproject ( main git ) only fetched main git contents and not the contents of the other gits (submodules) inside this git.

Command line execution

Terminalbash
git submodules to have one git directory inside another git directory. In our last post we created the repository at  https://github.com/lynxbee/understanding-git-submodules  , now lets try to clone the same as, $ git clone https://github.com/lynxbee/understanding-git-submodules   $ cd understanding-git-submodules/  $ tree . ├── README.superproject ├── submodule_one └── submodule_two 2 directories, 1 file As we can see with tree command, git clone of superproject ( main git ) only fetched main git contents and not the contents of the other gits (submodules) inside this git. Lets see how many submodules this repository contains from .gitmodules file as, $ cat .gitmodules  [submodule "submodule_one"]      path = submodule_one url = https://github.com/lynxbee/submodule_one.git  [submodule "submodule_two"]      path = submodule_two url = https://github.com/lynxbee/submodule_two.git here we need to initialise the git submodules as, $ git submodule init Submodule 'submodule_one' (https://github.com/lynxbee/submodule_one.git) registered for path 'submodule_one' Submodule 'submodule_two' (https://github.com/lynxbee/submodule_two.git) registered for path 'submodule_two' Now lets sync all the remote repositories, which will download all the submodules .. $ git submodule update Cloning into 'submodule_one'... remote: Counting objects: 3, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. Checking connectivity... done. Submodule path 'submodule_one': checked out 'bcf736c3d3ec573108d1c5f2b8dc98ed9cacea1e' Cloning into 'submodule_two'... remote: Counting objects: 3, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done. Checking connectivity... done. Submodule path 'submodule_two': checked out '352bc0f00df1c62711045afa09da98478d94c2a7' $ tree . ├── README.superproject ├── submodule_one │   └── README.md └── submodule_two     └── README.md

Implementation details

Lets see how many submodules this repository contains from .gitmodules file as, $ cat .gitmodules [submodule "submodule_one"] path = submodule_one url = https://github.com/lynxbee/submodule_one.git [submodule "submodule_two"] path = submodule_two url = https://github.com/lynxbee/submodule_two.git here we need to initialise the git submodules as, $ git submodule init Submodule 'submodule_one' (https://github.com/lynxbee/submodule_one.git) registered for path 'submodule_one' Submodule 'submodule_two' (https://github.com/lynxbee/submodule_two.git) registered for path 'submodule_two' Now lets sync all the remote repositories, which will download all the submodules .. $ git submodule update Cloning into 'submodule_one'... remote: Counting objects: 3, done. remote: Compressing objects: 100% (2/2), done. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 Unpacking objects: 100% (3/3), done.

Gotchas and common issues

  • Permission checks - verify user access rights and sudo privileges before executing system-level operations.

  • Environment configuration - double-check path variables and dependency versions to prevent runtime failures.

  • Backup safeguards - maintain configuration backups before applying system or database modifications.

Following these steps ensures clean configuration and reliable execution for clone remote git repository which has git submodules.