Does Tower automatically initialize submodules after a branch checkout that changes .gitmodules?
0 reputation · 11 Apr 2023, 04:49 UTC
0 reputation · 11 Apr 2023, 04:49 UTC
Tower includes built-in support for browsing and initializing Git submodules, but its behavior after a branch checkout that modifies .gitmodules is not clearly documented for macOS or Windows. Native Git does not initialize submodules during checkout unless explicitly configured, so the client must decide whether to run submodule update automatically.
The unresolved question is whether Tower performs recursive submodule initialization when the checked-out branch changes submodule paths or URLs, and whether that behavior is consistent across Tower major versions and operating systems. Incorrect assumptions can leave submodule folders empty after a branch switch.
Does Tower automatically initialize newly referenced submodules after a branch checkout that updates .gitmodules? Does this behavior differ between Tower for macOS and Tower for Windows? Is the automation affected by the installed Tower major version or by nested submodule depth?
37775 reputation · 11 Apr 2023, 07:54 UTC
Tower does not automatically initialize newly referenced submodules after a branch checkout that modifies .gitmodules by default. The client provides a preference that can trigger initialization, but its scope and behavior differ between macOS and Windows, and between major versions.
\nWhen the preference Automatically update submodules on checkout is enabled, Tower runs git submodule update --init --recursive after the checkout operation. If the preference is disabled, submodule folders remain at the previous commit or appear empty if the newly checked-out branch adds or redefines submodules in .gitmodules.
This preference is per-repository on macOS but global on Windows, which can create inconsistency when the same repository is used across both operating systems or when team members use different platforms.
\nAdditionally, if the native Git configuration submodule.recurse is set to true in .git/config, the Git CLI will auto-update submodules on checkout even when Tower’s preference is off, creating a discrepancy between the command line and the GUI.
\ngit config --get submodule.recurse can be run in the repository to check whether Git-level recursion is active.
To verify the current behavior in your setup, open Tower Preferences Git macOS or Settings Git Windows and confirm the state Automatically update submodules on checkout. Creating a test repository with two branches where one adds a new submodule in .gitmodules and checking out the second branch in Tower will confirm whether the folder populates.
\nMissing diagnostic detail: Which Tower major version and operating system are you using? The preference location and default behavior have changed between minor releases (e.g., Tower 9 on macOS, Tower 4 on Windows), and the answer may depend on your specific configuration.
Use comments to ask for clarification. Post a solution as an answer.
37,775 reputation · 11 Apr 2023, 10:16 UTC
Native Git checkout does not initialize submodules merely because .gitmodules changed; it leaves the working tree at the previously recorded submodule commit or empty. Tower-specific auto-initialization is not established behavior across versions or operating systems, so treat any preference or UI indicator as unverified until tested in your build.
Practical check: create a scratch repo with two branches differing only in .gitmodules, switch in Tower, then run git submodule status and inspect the submodule directory. Repeat on each Tower version and OS you support. If folders stay empty, run git submodule update --init --recursive manually or consider a post-checkout hook rather than assuming GUI automation.