

(2) Of course, this is reflected in our file structure: our project now contains a new "ToProgess" folder inside the "lib" directory.Remote: Total 180 (delta 51), reused 0 (delta 0), pack-reused 91 Remote: Compressing objects: 100% (89/89), done. (1) The command started a simple cloning process of the specified Git repository:.With the "git submodule add" command, we'll add a little Javascript library from GitHub: $ git submodule add In our sample project, we create a new "lib" folder to host this (and future) library code.
#GIT SUBMODULE ADD EXAMPLE HOW TO#
Let's see how to work with Submodules in practice. from inside it like with any other repository. In the common case of including a code library, you can simply add the library as a Submodule in your main project.Ī Submodule remains a fully functional Git repository: you can modify files, commit, pull, push, etc. The only specialty is that it is nested inside a parent repository. Repositories Inside RepositoriesĪ "Submodule" is just a standard Git repository. Since these are quite common problems in everyday projects, Git of course offers a solution: Submodules. Again, we need to download the raw files and replace the original items. Should the library change (because bugs were fixed or new features added), we'll have a hard time updating the library code.There's no need to keep these files in the same version control context as our project. The library, actually, is a project of itself and should be kept separate from our work. This mixes external code with our own, unique project files.By casually throwing those library files into your project, we're inviting a couple of problems: While this is a valid approach, it's not the cleanest one.
#GIT SUBMODULE ADD EXAMPLE MANUAL#
The manual way is to simply download the necessary code files, copy them to your project, and commit the new files into your Git repository. Often in a project, you want to include libraries and other resources. Learn on: Desktop GUI | Command Line Language: EN | CN Submodules
