# git submodule: update --remote --checkout + upstream branch change

1 messages from 2026-01-20 to 2026-01-20. Participants: D. Ben Knoble.
Thread: https://gitlist.dev/t/64832

## D. Ben Knoble, 2026-01-20 02:20

Subject: git submodule: update --remote --checkout + upstream branch change
Message-ID: <CALnO6CCkcp-Pj-M6yCnr3O-DJE3PedEcqGah3e+E9C4Awqf+Kg@mail.gmail.com>
URL: https://gitlist.dev/e/CALnO6CCkcp-Pj-M6yCnr3O-DJE3PedEcqGah3e%2BE9C4Awqf%2BKg%40mail.gmail.com

```
On my build of git.git origin/master (with ps/history merged in, but
that shouldn't affect this), I received a confusing error today:

    git submodule update --remote --checkout
    …
    Unable to find refs/remotes/origin/HEAD revision in submodule path
'…submod…'

Turns out the upstream repository had renamed the main branch from
master to main, and the git dir
(.git/modules/…submod…/refs/remotes/origin) still had

    ref: refs/remotes/origin/main

This is weird, because I could successfully "git fetch" inside the
submodule, and "git ls-remote" showed HEAD on the remote pointing at
the same place as refs/heads/main. In fact, I was so puzzled that I
didn't understand where this error had come from (grepping in the
source found builtin/submodule--helper.c; GIT_TRACE2=1 was not really
any help here), nor did I have very high hopes of solving it except
that I happened to know where to look for occurrences of "master" that
might need changed.

A simple "git -C …submod… remote set-head origin -a" solves the
problem; is there something the submodule code needs to do to handle
this more gracefully, such as fixing it automatically or letting the
user know what possible causes are? Or something I can do to avoid
this coming up with other repositories I use as submodules?

-- 
D. Ben Knoble

```
