Browsed by
Month: February 2020

Git submodules

Git submodules

Today I noticed for the first time the concept of submodules in git. While cloning a repository from GitHub I noticed that one folder in it remained empty. After having a closer look, I noticed a reference to another repository tree like this:

Here, the folder htslib is actually from a tree in a different repository. After I cloned the repository like this (I forked it before):

git clone https://github.com/fischuu/SE-MEI.git

the folder htslib remained empty. That is because files from submodules are not fetched by default. This needs to be done separately by first initializing the submodules (first, cd into the cloned repository)

git submodule init

and then update the files from it

git submodule update

After these steps, the repository should be complete. However, instead of initializing the submodule separately, there is also a shortcut to fetch them all in one step by adding an additional parameter to the cloning like this:

git clone --recurse-submodules https://github.com/fischuu/SE-MEI.git

More details to git submodules can be found here.