Submodules

Submodules can be quite difficult to manage on the command line, but Tower makes handling submodules easy.

Transcript
Submodules

A submodule is, in essence, a Git repository inside a Git repository. The provide a powerful way to integrate library code into your main project. However, they can be quite difficult to manage on the command line.

For example, submodule metadata (like paths and URLs) are handled in multiple locations in Git. This means that you should not change any of this data manually unless you can make sure that you’ve changed it everywhere.
In addition, you might have different revisions of a Submodule checked out on different branches of your project.

Let’s look at how Tower can help in making submodule handling easier.

Submodules are listed in the repository view, at the bottom of the sidebar. If we click on the submodule, we will see information about its current state. For example, we can see the currently checked out revision. Now, let’s switch to another branch in the same repository and check the submodule again. We now have a different revision checked out for that branch.

You might think - “Well, that’s good then!”, but this actually does not happen if you use Git Submodules on the command line. Git by itself does not correct the revision for you - you might be left with an incorrect version of your submodule after switching branches.

The fact that Tower takes care of this automatically is very helpful in making submodule handling an easier task.

To access the different actions that you can carry out on a submodule, you can simply right-click on it. In the contextual menu, you will see options such as Checking out the submodule, Fetching, Synchronising and so on.

Navigating inside the submodule is easy, too. Double-clicking the submodule takes you to the Working Copy of the submodule. You can always glance at the navigation bar to know exactly where you are located in the submodule and in the parent repository.

Submodules are a valuable addition to your Git toolkit - Hopefully, after watching this episode, you will also feel more comfortable working with them in Tower.