
#Create submodule git update#
Or we can use the Git Submodule Update command with the -init and the -recursive command after cloning the repository using the Git Clone command. We can use -recurse-submodules option with the Git Clone command to also clone the submodules. There are two ways to tell Git that we also want it to clone the submodules. When we clone a repository Git will not download any of the submodules of that repository. This is the file where Git will keep track of all our submodules.Īlso, our Git configurations are altered to add the new submodule. $ mkdir $ git submodule add Īlternatively, we can first navigate to the destination folder and then run the above command without adding the subdirectory name.Īfter running the above command Git will first start cloning the remote repository.Ī hidden file is created with the name of. It is a good idea to first create a separate subdirectory in your repository and then add all the submodules to that subdirectory. We need to pass the remote repository URL where the project that we want to embed is hosted. To add a submodule we use the Git Submodule Add command.

#Create submodule git how to#
Now that we know what Submodules are and what they are used for, let's look at how to create and use submodules in Git. Submodules also help us to use external libraries that we want to modify and use for our main project. We can make changes to the submodule without affecting the main project.
#Create submodule git code#

SubmoduleĪ Submodule is a Git Repository inside another Git Repository. Let's learn more about Submodules and how to use them in Git. But this approach is not the most efficient one. We can simply copy and paste the code needed from this external repository into our main project.

A lot of times the main project will need code from some other external repository or library. This Git Repository is called the parent of the Submodule. A Submodule is a Git Repository that is a subdirectory of another Git Repository.
