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

Re: v2.9.3 and v2.10.0: `name-ref' HEAD gives wrong branch name

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2016, 16:37 UTC
Message-ID
<xmqq8tulb45n.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<b1d35732-4b4c-e0c1-59da-44d3e3b28799@gmail.com>
Jakub Narębski <jnareb@gmail.com> writes:
Show 12 quoted lines
>> Have you tried "git symbolic-ref HEAD"?
>> 
>> $ git symbolic-ref HEAD
>> refs/heads/master
>> 
>> If you don't want the fully-qualified ref, you can add --short:
>> 
>> $ git symbolic-ref --short HEAD
>> master
>
> This does not work for detached HEAD, but perhaps you don't need
> to worry about this.

I am not sure what you mean by "does not work". Asking what ref HEAD points at to symbolic-ref will tell you it does not point at anything by exiting with non-zero status and that can be relied upon.

Asking "symbolic-ref HEAD" has been the way how "git branch" and other commands find out what branch is currently checked out for almost eternity ("git symbolic-ref" appeared in Git v0.99.8).

Previous: Steffen NurpmesoNext: Jakub Narębski
Message 6 of 7 in “v2.9.3 and v2.10.0: `name-ref' HEAD gives wrong branch name”
  1. Steffen NurpmesoSep 20, 2016
  2. Bryan TurnerSep 20, 2016
  3. Steffen NurpmesoSep 20, 2016
  4. Jakub NarębskiSep 21, 2016
  5. Steffen NurpmesoSep 21, 2016
  6. Junio C HamanoSep 21, 2016
  7. Jakub NarębskiSep 21, 2016

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.