{"thread":{"id":"64832","subject":"git submodule: update --remote --checkout + upstream branch change","startedAt":"2026-01-20T02:20:47Z","lastAt":"2026-01-20T02:20:47Z","messageCount":1,"participants":["D. Ben Knoble"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"534205","messageId":"CALnO6CCkcp-Pj-M6yCnr3O-DJE3PedEcqGah3e+E9C4Awqf+Kg@mail.gmail.com","threadId":"64832","inReplyTo":null,"subject":"git submodule: update --remote --checkout + upstream branch change","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-01-20T02:20:35Z","receivedAt":"2026-01-20T02:20:47Z","isPatch":false,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On my build of git.git origin/master (with ps/history merged in, but\nthat shouldn't affect this), I received a confusing error today:\n\n    git submodule update --remote --checkout\n    …\n    Unable to find refs/remotes/origin/HEAD revision in submodule path\n'…submod…'\n\nTurns out the upstream repository had renamed the main branch from\nmaster to main, and the git dir\n(.git/modules/…submod…/refs/remotes/origin) still had\n\n    ref: refs/remotes/origin/main\n\nThis is weird, because I could successfully \"git fetch\" inside the\nsubmodule, and \"git ls-remote\" showed HEAD on the remote pointing at\nthe same place as refs/heads/main. In fact, I was so puzzled that I\ndidn't understand where this error had come from (grepping in the\nsource found builtin/submodule--helper.c; GIT_TRACE2=1 was not really\nany help here), nor did I have very high hopes of solving it except\nthat I happened to know where to look for occurrences of \"master\" that\nmight need changed.\n\nA simple \"git -C …submod… remote set-head origin -a\" solves the\nproblem; is there something the submodule code needs to do to handle\nthis more gracefully, such as fixing it automatically or letting the\nuser know what possible causes are? Or something I can do to avoid\nthis coming up with other repositories I use as submodules?\n\n-- \nD. Ben Knoble\n"}]}