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

Re: Git clone behave strange after active branch change in bare repo

From
Jeff King <peff@peff.net>
Date
Mar 12, 2012, 11:12 UTC
Message-ID
<20120312111242.GA12921@sigill.intra.peff.net>
In-Reply-To
<CA+OUE95+Ux_+hSRJw6MH-kh54JewXx-fbWqBoh-Eh_P1tNwAFA@mail.gmail.com>
On Mon, Mar 12, 2012 at 11:10:03AM +0100, Zdenek Crha wrote:
> When I run git clone while 'master' and 'a_branch' point to same
> commit, I will get clone with default branch 'master' where I would
> expect default branch 'a_branch'.

Yes, this is a known issue. The git protocol does not transfer the contents of the symref; the client must guess the branch name from the set of refs that are advertised. This has been discussed before, and there were even some patches proposed, but I think nobody cared enough to push it through, as it requires an extension to the protocol.

You can search the list archives for past discussions.
Show 7 quoted lines
> I did few more checks and it seems to me that:
> 
> * when active branch is 'master' then default branch in clone is
> always master as expected
> * when active branch is different from 'master', then the default
> branch in clone is a first branch in alfabetically sorted list of
> branches that point to same commit as active branch
Exactly. The relevant code is in remote.c:guess_remote_head.
-Peff
Previous: Zdenek Crha
Message 2 of 2 in “Git clone behave strange after active branch change in bare repo”
  1. Zdenek CrhaMar 12, 2012
  2. Jeff KingMar 12, 2012

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.