![]() ![]() ![]() (a) You can add the "-recurse-submodules" option to "git clone" this tells Git to also initialize all Submodules when the cloning is finished. You have two options to end up with a populated "lib" folder (or wherever else you choose to save your Submodules "lib" is just an example): Our "lib" folder, however, would stay empty. This shows when you clone a project that contains Submodules: by default, the "git clone" command only downloads the project itself. You already know that a project repository does not contain its Submodules' files the parent repository only saves the Submodules' configurations as part of version control. Git regards adding a Submodule as a modification like any other - and requests you to commit it to the repository: $ git commit -m "Add 'ToProgress' Javascript library as Submodule"Ĭongratulations: we've now successfully added a Submodule to our main project! Before we look at a couple of use cases, let's see how you can clone a project that already has Submodules added. Let's have a look at our project's status: $ git status Please do yourself a favor and always use proper Git commands to manage Submodules. Therefore, it's highly recommended not to mess with configuration files and values manually. ![]() Git's internal management of Submodules is quite complex (as you can already guess from all the. As you can see from the ".git" subfolder contained herein, this is a fully-featured Git repository. (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. 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.
0 Comments
Leave a Reply. |