# default remote branch

2 messages from 2015-09-18 to 2015-09-21. Participants: Thibault Kruse, Junio C Hamano.
Thread: https://gitlist.dev/t/40379

## Thibault Kruse, 2015-09-18 09:50

Subject: default remote branch
Message-ID: <CAByu6UUxsWu5RVar=8uKJw3kZpxjawqbwABgNREjJ3g3mGDwVA@mail.gmail.com>
URL: https://gitlist.dev/e/CAByu6UUxsWu5RVar%3D8uKJw3kZpxjawqbwABgNREjJ3g3mGDwVA%40mail.gmail.com

```
Hi,

the 'git remote show <remote>' command shows the default branch among
other things.
The default branch being the branch that a clone will have immediately
after cloning.

Is it possible to run a command that only shows that default branch
for a given remote?

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.

So is there a sane way to get the last know default branch without
accessing the remote?
If so, is there a way to update local information about the default
branch of a remote?

cheers,
  Thibault

```

## Junio C Hamano, 2015-09-21 17:16

Subject: Re: default remote branch
Message-ID: <xmqqd1xbbsla.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqd1xbbsla.fsf%40gitster.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.

```
