

Out of curiosity, let’s check out the contents of that new file: $ cat. This new file contains the details we supplied about the new submodule. Notice how the supplied path was created and added to the changes to be committed. Let’s check to see how the repository is doing. lib/billboard – This is the path where the submodule repository will be added to the main repository.You need to ensure that you have the ability to clone the given repository. The exact syntax will vary depending on the setup of the Git repository you are connecting to. – This is the external repository that is to be added as a submodule.git submodule add – This simply tells Git that we are adding a submodule.There are three main parts to this command: Remote: Total 1006 (delta 631), reused 0 (delta 0)

Initialized empty Git repository in ~/git_dev/SampleTheme/lib/billboard/.git/ For example, if I’m in the repository working directory of a new theme called SampleTheme and need to add the billboard repository to the path lib/billboard, I can do so with the following command: $ git submodule add lib/billboard Adding Submodules to a Git Repositoryįortunately, adding a submodule to a git repository is actually quite simple.

#GIT ADD REMOTE PATH HOW TO#
In order, you will need to know how to add, make use of, remove, and update submodules. There are four main functions you will need to understand in order to work with Git submodules.

#GIT ADD REMOTE PATH CODE#
Since I’m using submodules, the code can be pulled directly from the relevant submodule repositories rather than requiring me to manually update each individual theme repository.Īs I mentioned before, not everything in Git is easy to work with. FlexxBold currently includes a total of seven submodules: billboard, contact-page-plugin, featured-images, feedburner-widget, file-utility, flexx-layout-editor, and tutorials. Rather than actually putting the feature module code directly into the theme repositories, I simply add the needed feature module repositories as submodules.įor example, we have a theme called FlexxBold. In addition, I’ve created a separate repository for each one of these feature modules. This allows for the code to be easily added to other themes and also simplifies code updates/improvements as the code for specific features is consistent across all the themes that use that specific module.Įach theme that we produce is kept in its own Git repository. I develop the code for these enhancements in modules that are completely contained in their own folder. Basically, I develop feature enhancements to the themes. My profession is working with WordPress themes. In order to illustrate the value of submodules, it will probably be helpful for me to explain how I am using them. It essentially allows you to attach an external repository inside another repository at a specific path. I’ll cover two of the more difficult things to figure out: removing and updating submodules from your repository. I say “figuring out” because not everything about working with submodules is well documented. While the concept of submodules is simple, figuring out how to actually work with them can be a chore. Submodules specifically have managed to be a thorn in my side on many occasions. I can honestly say that while there are many things that I like about Git, there are just as many things that I personally find to be a pain in the butt. I’ve spent a little more than a month working with Git now.
