top of page
Search

Using Submodules with TortoiseGit

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

  1. Right-click on your main repository and select TortoiseGit → Submodule Add.

  2. In the window that appears, enter the URL of the repository to be added as a submodule.

  3. Specify the path where you want to place the submodule inside your project.

  4. Click OK.

Updating a Submodule

  1. Right-click on the submodule you want to update and select TortoiseGit → Submodule Update.

  2. TortoiseGit will fetch the data from the submodule’s repository and check out the commit recorded in the main repository.

Removing a Submodule

  1. Delete the relevant section from the .gitmodules file.

  2. Stage the .gitmodules changes via command line using git add .gitmodules.

  3. Delete the relevant section from .git/config.

  4. Run git rm --cached path_to_submodule (no trailing slash).

  5. Commit the changes with git commit -m "Removed submodule <name>".

  6. 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.


6 views0 comments

Recent Posts

See All

Using Git Submodules: A Guide for Software Developers

July 6, 2023 I. Introduction A. Overview of Git Git is a version control system (VCS) that allows software developers to track changes in their code, collaborate with teams, and maintain multiple vers

bottom of page