git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sjoerd Langkemper <sjoerd-2021@linuxonly.nl>
To: git@vger.kernel.org
Subject: Git submodule update remote keeps using previous default branch
Date: Fri, 15 Oct 2021 10:34:49 +0200	[thread overview]
Message-ID: <CAA1vfca+kPSsitsZad-bmrd+o1ay60NXZrH2zGLpwN69Px-rtw@mail.gmail.com> (raw)

I am having trouble with git 2.33.1 checking out the wrong branch for
submodules for which the default branch has changed. `git submodule
update --remote` seems to remember the branch name to retrieve, while
I expect it to use the remote HEAD every time. This causes unexpected
behaviour when the remote HEAD starts pointing to another branch.

I create a new git project and add a submodule, with `git submodule
add git@host:foo/testproject.git`.

This checks out the default branch, `master` in this case. `git remote
show origin` also shows that `master` is the HEAD branch. Running `git
submodule update --remote` updates the submodule to the latest master.

Now I change the default branch on the remote (using Gitlab's web
interface) to `newmaster`.

`git remote show origin` now correctly shows `newmaster` as the
remote's HEAD branch. However, running `git submodule update --remote`
still updates the submodule to the latest `master` branch, while I
expect it to update to the lastest `newmaster` branch.

There's no branch specified in .gitmodules or .git/config. I am not
sure how git remembers the branch. When switching `testproject` to
`newmaster` manually and then running `git submodule update --remote`,
it is reset to `master` again.

Is this a bug? Can I change the branch somehow?

Regards,

Sjoerd Langkemper

             reply	other threads:[~2021-10-15  8:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-15  8:34 Sjoerd Langkemper [this message]
2021-10-15  9:05 ` Git submodule update remote keeps using previous default branch Bryan Turner
2021-10-15 10:45 ` Sjoerd Langkemper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAA1vfca+kPSsitsZad-bmrd+o1ay60NXZrH2zGLpwN69Px-rtw@mail.gmail.com \
    --to=sjoerd-2021@linuxonly.nl \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).