git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: default remote branch

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2015, 17:16 UTC
Message-ID
<xmqqd1xbbsla.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<CAByu6UUxsWu5RVar=8uKJw3kZpxjawqbwABgNREjJ3g3mGDwVA@mail.gmail.com>
Thibault Kruse <tibokruse@googlemail.com> writes:
> Also, I tried finding out whether I can use the
> .git/refs/remotes/<remote>/HEAD to check the default branch without
> accessing the remote. However, I find this file is not updated with a
> git fetch, nor created when missing.

That is more or less deliberate. Which one of the branches to consider the primary one becomes a local decision after you clone. If that was a good choice may be debatable, but that is how existing users expect things to work.

> So is there a sane way to get the last know default branch without
> accessing the remote?

"The last known" is not updated, due to "where remotes/origin/HEAD points at is a local matter" design; there is nothing that locally stores the information you are asking for, so there is no offline way to answer that question.

An early part of the protocol exchange "git clone" does carry that information, but I do not think there is a command to ask that to the remote. A logical place to add it would be a new option to "git ls-remote", I would think.

Previous: Thibault Kruse
Message 2 of 2 in “default remote branch”
  1. Thibault KruseSep 18, 2015
  2. Junio C HamanoSep 21, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.