Git Submodules allow you to keep a Git repository as a subdirectory of another Git repository. This allows you to clone another repository into your project and keep your commits separate.
Adding a Submodule
Right-click on your main repository and select TortoiseGit → Submodule Add.
In the window that appears, enter the URL of the repository to be added as a submodule.
Specify the path where you want to place the submodule inside your project.
Click OK.
Updating a Submodule
Right-click on the submodule you want to update and select TortoiseGit → Submodule Update.
TortoiseGit will fetch the data from the submodule’s repository and check out the commit recorded in the main repository.
Removing a Submodule
Delete the relevant section from the .gitmodules file.
Stage the .gitmodules changes via command line using git add .gitmodules.
Delete the relevant section from .git/config.
Run git rm --cached path_to_submodule (no trailing slash).
Commit the changes with git commit -m "Removed submodule <name>".
Delete the untracked submodule files rm -rf .git/modules/path_to_submodule and rm -rf path_to_submodule.
Remember to replace path_to_submodule with the path to your submodule.
Comments