Thank you for filling out a Git bug report! Please answer the following questions to help us understand your issue. What did you do before the bug happened? (Steps to reproduce your issue) I have a repo (https://github.com/adafruit/circuitpython) with a large number of submodules. When switching branches we have a `make fetch-all-submodules` command that runs `git submodule update --init` under the hood. What did you expect to happen? (Expected behavior) The data/nvm.toml submodule should update to the commit set by the state of the outer repo. What happened instead? (Actual behavior) env GIT_TRACE=1 git submodule update --init data/nvm.toml/ 16:33:38.062849 git.c:749 trace: exec: git-submodule update --init data/nvm.toml/ 16:33:38.062882 run-command.c:659 trace: run_command: git-submodule update --init data/nvm.toml/ 16:33:38.077269 git.c:463 trace: built-in: git rev-parse --git-dir 16:33:38.079447 git.c:463 trace: built-in: git rev-parse --git-path objects 16:33:38.083204 git.c:463 trace: built-in: git rev-parse --show-prefix 16:33:38.085057 git.c:463 trace: built-in: git rev-parse --show-toplevel 16:33:38.089671 git.c:463 trace: built-in: git submodule--helper update --init -- data/nvm.toml/ 16:33:38.091052 run-command.c:1523 run_processes_parallel: preparing to run up to 1 tasks 16:33:38.091061 run-command.c:1551 run_processes_parallel: done 16:33:38.091934 run-command.c:659 trace: run_command: cd data/nvm.toml; unset GIT_PREFIX; GIT_DIR=.git git rev-list -n 1 427cc923976229bcb981ca6f218ebe8efd636df6 --not --all 16:33:38.093709 run-command.c:659 trace: run_command: cd data/nvm.toml; unset GIT_PREFIX; GIT_DIR=.git git fetch 16:33:38.094641 git.c:463 trace: built-in: git fetch 16:33:38.094933 run-command.c:659 trace: run_command: git remote-https origin https://github.com/adafruit/nvm.toml.git 16:33:38.095835 git.c:749 trace: exec: git-remote-https origin https://github.com/adafruit/nvm.toml.git 16:33:38.095861 run-command.c:659 trace: run_command: git-remote-https origin https://github.com/adafruit/nvm.toml.git 16:33:38.352385 run-command.c:1523 run_processes_parallel: preparing to run up to 1 tasks 16:33:38.352401 run-command.c:1551 run_processes_parallel: done 16:33:38.352407 run-command.c:659 trace: run_command: git maintenance run --auto --no-quiet 16:33:38.353616 git.c:463 trace: built-in: git maintenance run --auto --no-quiet 16:33:38.354265 run-command.c:659 trace: run_command: cd data/nvm.toml; unset GIT_PREFIX; GIT_DIR=.git git rev-list -n 1 427cc923976229bcb981ca6f218ebe8efd636df6 --not --all 16:33:38.356060 run-command.c:659 trace: run_command: cd data/nvm.toml; unset GIT_PREFIX; GIT_DIR=.git git fetch adafruit321 427cc923976229bcb981ca6f218ebe8efd636df6 16:33:38.357177 git.c:463 trace: built-in: git fetch adafruit321 427cc923976229bcb981ca6f218ebe8efd636df6 fatal: transport 'file' not allowed fatal: Fetched in submodule path 'data/nvm.toml', but it did not contain 427cc923976229bcb981ca6f218ebe8efd636df6. Direct fetching of that commit failed. What's different between what you expected and what actually happened? The submodule update is unable to find the target commit even though it is present in the submodule's repo. Anything else you want to add: Looking at the trace I noticed it's doing `git fetch adafruit321 ...` instead of the correct `git fetch origin ...`. (The `git remote-https origin` command is correct.) adafruit321 is the default branch in `.git/config` for my outer repo's branch (not the submodule). It looks like `fetch_in_submodules` is using the wrong default branch: https://github.com/git/git/blob/next/builtin/submodule--helper.c#L2241C31-L2241C31 Please review the rest of the bug report below. You can delete any lines you don't wish to share. [System Info] git version: git version 2.42.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 6.4.12-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 24 Aug 2023 00:38:14 +0000 x86_64 compiler info: gnuc: 13.2 libc info: glibc: 2.38 $SHELL (typically, interactive shell): /usr/bin/fish [Enabled Hooks] pre-commit