![]() ‘…’), or incoming / outgoing changes (up/down arrow). Submodule entries can also have annotations to let you know if there are uncommitted changes in the submodule (ellipsis annotation, i.e. If you wanted to see more detail about the submodule, just double-click on it to open it in its own repository window, from which you can, if you like, make changes to it just like any other repository. This tells you that your submodule is located in dependencies/sub1 and is currently on the ‘master’ branch. Once the submodule has cloned, you’ll see it appear in the sidebar like this: You’ll then be prompted to provide a source URL to clone the contents from, and the path within the current repository that this submodule will reside. Adding a submodule to your projectĪdding a new submodule to your project is simple, just right-click on a blank area of the sidebar and select ‘New Submodule’ (or select it from the Repository menu). The most common reason for wanting to do this is that your project has dependencies on other code bases (libraries for example), and you want to track those from their original sources rather than duplicating the files within your own repository.įor the sake of brevity from here on I’ll use the term ‘submodule’ to mean ‘subrepository’ as well, unless I’m talking about a Mercurial-specific feature. The terms may be different, but they refer to the same concept that of nesting other repositories within the folder structure of your own repository. I believe that this movement towards abstraction and transposable components will prove advantageous.Using submodules and subrepositories By Steve on February 1, 2012Ī headline feature of SourceTree 1.3 is the support for submodules (in Git) and subrepositories (in Mercurial). It reminds me of other package managers like NPM. I truly appreciate the modularity and extensibility that Git submodules provide. Furthermore, this will allow me to swap out the theme for a new one with relative ease. Having the forked theme as a Git submodule allows me to update either the blog's content or its theme separately. This is the type of abstraction that I love.Īs a result, if you check out my blog repository's theme folder, you can see that it is referencing a fork of a theme as a Git submodule. My Hugo blog repository only needs to know about the content I have and should not care about which theme is used. I eventually found a theme I liked and discovered that many other people included their themes as submodules in order to improve modularity. Hugo is a static site generator that allows the customization of the site via themes. When I was migrating my blog from Wordpress to Hugo, I got a first-hand experience with dealing with Git submodules. ![]() You can navigate into the submodule folder and use git pull origin master if you want updates from the master branch. Updating Existing SubmodulesĪfter you have the submodule initialized within your local repository, you can retrieve the latest changes like you would in a normal repository. The -recursive option updates all nested submodules as well. The -init option is if the submodule is not initialized (cloned) yet. The update command will pull in the latest revision on the server. You can ammend this issue by adding -recursive or -recurse-submodules to your git clone command. This is because Git does not recursively clone submodules by default. However, after cloning, you discover that the directory containing the submodule is empty. Let's say there is a project with submodules that you wish to clone onto your local computer. This post will primarily cover how to update the submodule component for your existing projects. You can follow the above link for more information on how to get started with Git submodules. As a result, the modifications to either projects are kept separate. One recommendation is to use Git submodules in order to store the external library's Git repository as a subdirectory of your own Git repository. Following this process will create complications when merging with upstream changes. This method makes it difficult to modify the source code of the library if that becomes necessary.įurthermore, simply copying the source code into your own project creates a tightly coupled system. If you want control over the library, including the library via a CDN or package manager is not optimal. What is the best way to bundle those external libraries with your project? When creating software, we often utilize other libraries or packages to create a separation of concerns or to prevent reinventing the wheel. ![]() A Git submodule is a reference to another project.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |