2.12. Submodules

TortoiseGit

2.12. Submodules

When you want to embed foreign repositories into a working tree/git repository, this is called a submodule. Here using the TortoiseGitSubmodules Add option a foreign repository can be embedded into a dedicated subdirectory of the source tree. When selecting this option, a dialog pops up:

Figure 2.21. The add submodule dialog

The add submodule dialog

Here you can enter the location/URL of the Repository you want to embed into the directory Path. Path can be entered as a relative path within the active source tree, but can also be an absolute path (pointing to the active source tree). The folder should be empty or non existent. If you don't want to integrate the HEAD of the Repository, you can enter a different Branch. By pressing OK, the entered Repository is cloned and integrated into the current source tree.

If a working tree contains submodules, two new context menu entries are available:

Figure 2.22. Submodule context menu entries

Submodule context menu entries


Submodule Update:

Figure 2.23. The update submodule dialog

The update submodule dialog


Initialize the submodules and/or update the registered submodules, i.e. clone missing submodules and checkout the commit specified in the index of the containing repository.

Submodule Sync: Synchronizes submodules' remote URL configuration setting to the value specified in .gitmodules. This is useful when submodule URLs change upstream and you need to update your local repositories accordingly.

Also if a working tree contains submodules, Section 2.4, “Checking Out A Working Tree (Switch to commit)” and Section 2.24, “Reset” contain a button for updating submodules:

Figure 2.24. Button for updating submodules in progress dialog

Button for updating submodules in progress dialog


You can find more information at Section G.3.131, “git-submodule(1)”.