{"thread":{"id":"63711","subject":"changed output in git branch -a","startedAt":"2025-06-30T11:03:41Z","lastAt":"2025-06-30T14:20:03Z","messageCount":4,"participants":["Olaf Hering","Kristoffer Haugsbakk","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"520912","messageId":"20250630121839.6252d9d9.olaf@aepfle.de","threadId":"63711","inReplyTo":null,"subject":"changed output in git branch -a","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2025-06-30T10:23:32Z","receivedAt":"2025-06-30T11:03:41Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"Hello,\n\nmy dumb script parses the output of \"git --git-dir=some/dir/.git branch -a\".\nWith git 2.43 it gets the expected list of \"remote/branch\".\nWith git 2.50 it also gets something like \"remote/HEAD -> remote/branch\".\n\nThe newer version runs on a different system. It might be that the repository\nwas already cloned with a different format. For some reason it does have\n.git/refs/remotes/${remote}/HEAD, but the system with the older git lacks\nthat entry.\n\nIs there a way to suppress such lines, or do I need to filter them manually?\nThere is no obvious knob mentioned in git-branch(1).\n\n\nThanks,\nOlaf\n"},{"id":"520913","messageId":"55b294bc-833d-4115-823a-2008657e68dc@app.fastmail.com","threadId":"63711","inReplyTo":"20250630121839.6252d9d9.olaf@aepfle.de","subject":"Re: changed output in git branch -a","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-06-30T11:13:56Z","receivedAt":"2025-06-30T11:14:17Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Mon, Jun 30, 2025, at 12:23, Olaf Hering wrote:\n> Hello,\n>\n> my dumb script parses the output of \"git --git-dir=some/dir/.git branch -a\".\n> With git 2.43 it gets the expected list of \"remote/branch\".\n> With git 2.50 it also gets something like \"remote/HEAD -> remote/branch\".\n>\n> The newer version runs on a different system. It might be that the repository\n> was already cloned with a different format. For some reason it does have\n> .git/refs/remotes/${remote}/HEAD, but the system with the older git lacks\n> that entry.\n>\n> Is there a way to suppress such lines, or do I need to filter them manually?\n> There is no obvious knob mentioned in git-branch(1).\n\nCan you use something like\n\n    git for-each-ref --format='%(refname:short)' --exclude='**/HEAD'\n\nInstead?  The output of this f-e-r command is stable.\n\n-- \nKristoffer Haugsbakk\n\n"},{"id":"520915","messageId":"xmqqsejh5pam.fsf@gitster.g","threadId":"63711","inReplyTo":"20250630121839.6252d9d9.olaf@aepfle.de","subject":"Re: changed output in git branch -a","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-06-30T13:31:29Z","receivedAt":"2025-06-30T13:31:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Olaf Hering <olaf@aepfle.de> writes:\n\n> my dumb script parses the output of \"git --git-dir=some/dir/.git branch -a\".\n> With git 2.43 it gets the expected list of \"remote/branch\".\n> With git 2.50 it also gets something like \"remote/HEAD -> remote/branch\".\n>\n> The newer version runs on a different system. It might be that the repository\n> was already cloned with a different format. For some reason it does have\n> .git/refs/remotes/${remote}/HEAD, but the system with the older git lacks\n> that entry.\n\nI somehow do not think this is a version difference.  Assuming that\nyour default remote is called \"origin\", I suspect that you have\nrefs/remotes/origin/HEAD symbolic ref in the repository you use with\nGit 2.50, while in the other repository you do not.  Both versions\nare capable of showing that symbolic ref information.\n\nYou can try in the repository where you use Git 2.43\n\n    $ git remote set-head origin -a\n    $ git branch -a\n\nto see if the difference indeed is coming from different versions.\n\n\n> Is there a way to suppress such lines, or do I need to filter them manually?\n> There is no obvious knob mentioned in git-branch(1).\n\nScripts should be reading \"git for-each-ref\" output in the first\nplace. Output from \"git branch\" is meant for human consumption and\nis subject to change any time (even though in this case I suspect it\nhas not changed.\n\n"},{"id":"520920","messageId":"20250630161953.3824c610.olaf@aepfle.de","threadId":"63711","inReplyTo":"xmqqsejh5pam.fsf@gitster.g","subject":"Re: changed output in git branch -a","fromName":"Olaf Hering","fromEmail":"olaf@aepfle.de","sentAt":"2025-06-30T14:19:53Z","receivedAt":"2025-06-30T14:20:03Z","isPatch":false,"sender":{"key":"olaf@aepfle.de","avatar":"https://avatars.githubusercontent.com/u/942324?v=4"},"body":"Mon, 30 Jun 2025 06:31:29 -0700 Junio C Hamano <gitster@pobox.com>:\n\n> You can try in the repository where you use Git 2.43\n>     $ git remote set-head origin -a\n>     $ git branch -a\n> to see if the difference indeed is coming from different versions.\n\nThanks, it does not depend on the version. For some reason the repository\non the system with the older git had no default branch set. The repository\nwas cloned a long time ago, maybe default branches were never set initially.\n\nI changed my script to use for-each-ref.\n\n\nOlaf\n"}]}