Failed to recurse into submodule path — submodule update/checkout failure
ID: git/submodule-update-failed
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
Submodule update failures occur when: the submodule isn't initialized, the referenced commit doesn't exist in the submodule repo, network issues prevent fetching, or the .gitmodules config has incorrect URLs. The error 'reference is not a tree' means the parent repo references a submodule commit that the submodule repo doesn't have.
genericWorkarounds
-
93% success Initialize and update submodules recursively
Run 'git submodule update --init --recursive'. This initializes any uninitialized submodules, fetches the referenced commits, and checks them out. The --recursive flag handles nested submodules. For initial clone, use 'git clone --recurse-submodules <url>'.
-
88% success Force sync submodule URLs from .gitmodules
If submodule URLs have changed, run 'git submodule sync --recursive' to update the submodule remote URLs from .gitmodules, then 'git submodule update --init --recursive' to fetch and checkout. This fixes issues when the submodule repo has moved.
-
90% success Deinitialize and re-initialize a broken submodule
Run 'git submodule deinit -f <path>' to remove the submodule working directory and config, then 'git submodule update --init <path>' to re-clone and checkout. This is the clean reset for a broken submodule.
-
87% success Use git push --recurse-submodules=on-demand to auto-push submodules
Run 'git push --recurse-submodules=on-demand' to automatically push submodule commits before pushing the parent. Or set it as default: 'git config push.recurseSubmodules on-demand'. This prevents the 'reference is not a tree' error for other developers.
Sources: https://git-scm.com/docs/git-push
Dead Ends
Common approaches that don't work:
-
Running git pull expecting submodules to update automatically
90% fail
git pull only updates the parent repository. Submodules are pinned to specific commits and must be explicitly updated with 'git submodule update'. The parent repo records WHICH commit to use, but doesn't automatically fetch/checkout that commit in the submodule directory.
-
Deleting the submodule directory and re-cloning it manually
85% fail
Manually cloning into the submodule directory creates a standalone repo that's disconnected from the parent's submodule tracking. The .git link, index entries, and .gitmodules configuration won't be properly set up. Use 'git submodule deinit' followed by 'git submodule update --init' instead.
-
Committing submodule changes without pushing the submodule repo first
88% fail
When you make commits inside a submodule and update the parent to reference the new commit, you must push the submodule BEFORE pushing the parent. Otherwise, other clones will reference a submodule commit that doesn't exist on the remote, causing 'reference is not a tree' errors.