Vault7: CIA Hacking Tools Revealed
Navigation: » Latest version
Owner: User #524297
Use Git Submodules to Manage Libraries
The Dilemma: Using Libraries in Projects under Version Control
How do we maintain a project dependency on a library already under version control? Rather than copying the libraries source to a subdirectory in our project,
Git Submodules
What if we could maintain a Git repository within a Git repository? You can! With Git submodules.
Git submodules are essentially that. Submodules allow you to tie your project code to a specific hash of another git repository.
Typically, your project would depend on a particular version of a library. So, in practice, you would ensure that your submodule ties you to the specific tagged revision of that library, which will be a single commit object.
Step-by-step guide to adding a Git submodule to your project
Adding a submodule to your project is the easy part.
-
In your project, run the below submodule command to add a subdirectory to your project that will contain the submodule repository.
- When you enter the submodule directory for the first time, you will
Step-by-step guide to cloning the repository with submodules
Using submodules will change how you have to initially clone the repository.
If after you clone, you find that the directories that should contain the submodules are empty, then run the below commands.
Use one of the following sets of commands to clone the repository and pull in all of its submodules.
git clone <git URL>
git submodule init
git submodule update
------
git clone <git URL>
git submodule update --init --recursive
------
git clone --recursive <git URL>
Related articles
('contentbylabel' missing)
('details' missing)