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

remote's HEAD not detected correctly

From
JMJeffrey Middleton <jefromi@gmail.com>
Date
Feb 28, 2011, 20:52 UTC
Message-ID
<AANLkTimWieViK4JcJQuTDiRiAdyvHuwkwy8fL+XUV+i-@mail.gmail.com>

There appears to be some weirdness here - git isn't properly looking at the HEAD of the remote repository

#!/bin/bash

(mkdir project && cd project && git init -q && touch a && git add a && git commit -q -m "add a" && git checkout -q -b pu) && git clone -q project project.clone && (cd project.clone && echo -n "HEAD: " && git symbolic-ref HEAD && echo -n "origin/HEAD: " && git symbolic-ref refs/remotes/origin/HEAD && git remote show origin)

The output is:
HEAD: refs/heads/master
origin/HEAD: refs/remotes/origin/master
* remote origin
  Fetch URL: /home/jefromi/sandbox/project
  Push  URL: /home/jefromi/sandbox/project
  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    master
    pu
8< more git remote output 8<

So somehow, the clone misses the fact that origin's HEAD is pu, not master, and git remote is only partially aware of this. It looks like this only happens when the two branches in question are pointing to the same commit; perhaps git is trying to guess what HEAD is via the SHA1? I know that ls-remote prints an SHA1, not a refname, for HEAD - is it not actually possible to get that information through a general transport protocol?

Jeffrey
Next: Shawn Pearce
Message 1 of 4 in “remote's HEAD not detected correctly”
  1. Jeffrey MiddletonFeb 28, 2011
  2. Shawn PearceFeb 28, 2011
  3. Jeff KingFeb 28, 2011
  4. Junio C HamanoFeb 28, 2011

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.