issue with git submodules and a clone.defaultRemoteName different than origin?
- From
Jacob Keller <jacob.e.keller@intel.com>
- Date
- Jun 3, 2025, 23:06 UTC
- Message-ID
- <4f638125-39e0-43a1-9c58-35c2d433042f@intel.com>
Hi,
I recently ran into an issue with git submodules because my clone.defaultRemoteName is not "origin":
Show 6 quoted lines
> fatal: 'origin' does not appear to be a git repository > fatal: Could not read from remote repository. > > Please make sure you have the correct access rights > and the repository exists. > fatal: Fetched in submodule path 'submodule', but it did not contain <redacted>. Direct fetching of that commit failed.
This appears to be due to the builtin/submodule--helper hard coding "origin" in "repo_get_default_remote".
I am unsure what the best way to fix this is. I could have the function read the clone.defaultRemoteName, or I could have it check if there is only one remote then use that.. or maybe add a new submodule remote name option?
Thoughts on what the best solution is here?
I'm thinking the following:
1) check if there is only one remote, then use that 2) check clone.defaultRemoteName and use that otherwise 3) fall back to origin otherwise?
Perhaps we could insert a step 0 where we add a config option which will have submodule clones use the given remote name + use that as the default when in detached head state?
Thanks, Jake