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

Re: changed output in git branch -a

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 30, 2025, 13:31 UTC
Message-ID
<xmqqsejh5pam.fsf@gitster.g>
In-Reply-To
<20250630121839.6252d9d9.olaf@aepfle.de>
Olaf Hering <olaf@aepfle.de> writes:
Show 8 quoted lines
> my dumb script parses the output of "git --git-dir=some/dir/.git branch -a".
> With git 2.43 it gets the expected list of "remote/branch".
> With git 2.50 it also gets something like "remote/HEAD -> remote/branch".
>
> The newer version runs on a different system. It might be that the repository
> was already cloned with a different format. For some reason it does have
> .git/refs/remotes/${remote}/HEAD, but the system with the older git lacks
> that entry.

I somehow do not think this is a version difference. Assuming that your default remote is called "origin", I suspect that you have refs/remotes/origin/HEAD symbolic ref in the repository you use with Git 2.50, while in the other repository you do not. Both versions are capable of showing that symbolic ref information.

You can try in the repository where you use Git 2.43
    $ git remote set-head origin -a
    $ git branch -a
to see if the difference indeed is coming from different versions.
> Is there a way to suppress such lines, or do I need to filter them manually?
> There is no obvious knob mentioned in git-branch(1).

Scripts should be reading "git for-each-ref" output in the first place. Output from "git branch" is meant for human consumption and is subject to change any time (even though in this case I suspect it has not changed.

Previous: Kristoffer HaugsbakkNext: Olaf Hering
Message 3 of 4 in “changed output in git branch -a”
  1. Olaf HeringJun 30, 2025
  2. Kristoffer HaugsbakkJun 30, 2025
  3. Junio C HamanoJun 30, 2025
  4. Olaf HeringJun 30, 2025

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.