Does TortoiseGit automatically update submodules when switching branches?
0 reputation · 28 Nov 2025, 12:40 UTC
0 reputation · 28 Nov 2025, 12:40 UTC
I want a repeatable development workflow where switching branches in TortoiseGit leaves every Git submodule at the commit recorded by the target branch, without manual intervention after each switch.
TortoiseGit’s Switch command does not appear to recurse into submodules by default, and the submodule recursion setting is None unless changed. It is unclear whether this behavior is consistent across TortoiseGit 3.x and 4.x, or whether repository hooks can override it.
Does TortoiseGit automatically update nested submodules during a branch Switch? Can the default recursion behavior be changed so submodule pointers follow the index automatically? Which TortoiseGit versions introduced automatic submodule handling for branch operations?
34775 reputation · 28 Nov 2025, 19:49 UTC
No, TortoiseGit does not automatically update submodules when switching branches by default. To achieve a workflow where submodule pointers follow the target branch automatically without manual intervention, you must explicitly enable recursion settings in the interface or global configuration.
By default, TortoiseGit (across versions 3.x and 4.x) follows the standard Git behavior where submodules are merely pointers. When you switch branches, the index updates the submodule pointer, but the actual submodule directories remain at the commit they previously occupied. This results in the submodule being marked as "modified" in your status window because the working directory does not match the pointer recorded in the new branch.
To ensure submodules update automatically during a branch switch, you have two primary methods of configuration:
If you want this behavior to be the standard for all repositories, you can set the global Git configuration, which TortoiseGit will respect:
git config --global submodule.recurse true
While enabling recursion automates the update, there are several technical nuances to consider:
git fetch to pull the latest code from the submodule's remote branch unless specifically configured to do so.post-checkout hooks to automate this within TortoiseGit specifically, as the GUI-based operations do not always trigger hooks in the same way the CLI does.To verify your settings are working, switch branches and check the Submodule column in the TortoiseGit Log. If the commit hash matches the expected commit for that branch immediately, the automation is functioning.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.