{"thread":{"id":"63529","subject":"Bug in git branch --show-current","startedAt":"2025-05-27T07:08:02Z","lastAt":"2025-05-27T08:36:39Z","messageCount":3,"participants":["Ulrich Wittenberg","Kristoffer Haugsbakk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"518957","messageId":"FR0P281MB28795FB4A108A6044273B39C9464A@FR0P281MB2879.DEUP281.PROD.OUTLOOK.COM","threadId":"63529","inReplyTo":null,"subject":"Bug in git branch --show-current","fromName":"Ulrich Wittenberg","fromEmail":"ulrich.wittenberg@kisters.de","sentAt":"2025-05-27T07:00:37Z","receivedAt":"2025-05-27T07:08:02Z","isPatch":false,"sender":{"key":"ulrich.wittenberg@kisters.de","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\nThis is part of a Jenkins job, so for some reason we are working on a detached head\n\nWhat did you expect to happen? (Expected behavior)\nI need to find out▒which branch the script is working on,\nso I used \"git branch --show-current\" to get this info.\n\nWhat happened instead? (Actual behavior)\nThe command returns absolutely nothing.\n\nWhat's different between what you expected and what actually happened?\nWell, everything!\n\nAnything else you want to add:\nI tried some other git commands that usually also show information\nabout the current branch, but *none* of them work or even show a fatal error.\n\n\n[System Info]\ngit version:\ngit version 2.39.5\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 6.1.0-34-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.135-1 (2025-04-25) x86_64\ncompiler info: gnuc: 12.2\nlibc info: glibc: 2.36\n$SHELL (typically, interactive shell): /bin/zsh\n\n\n[Enabled Hooks]\n\nUlrich Wittenberg\nSenior Software Developer | KISTERS Oldenburg\nGermany\n\nulrich.wittenberg@kisters.de\nwww.kisters.de\n\n\n\n________________________________\nUlrich Wittenberg - Energy - KISTERS AG - Haselriege 13 - 26125 Oldenburg - DE | +49 441 93602 -156 | ulrich.wittenberg@kisters.de | www.kisters.de | Handelsregister Aachen, HRB-Nr. 7838 | Vorstand: Klaus Kisters, Hanns Kisters | Aufsichtsratsvorsitzender: Dr. Thomas Klevers\nThis e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.\nDiese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.\n"},{"id":"518958","messageId":"24a091bf-daef-4c97-b233-1a0f5c329f25@app.fastmail.com","threadId":"63529","inReplyTo":"FR0P281MB28795FB4A108A6044273B39C9464A@FR0P281MB2879.DEUP281.PROD.OUTLOOK.COM","subject":"Re: Bug in git branch --show-current","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-05-27T07:24:58Z","receivedAt":"2025-05-27T07:27:56Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"On Tue, May 27, 2025, at 09:00, Ulrich Wittenberg wrote:\n> What happened instead? (Actual behavior)\n> The command returns absolutely nothing.\n\nThis is the documented behavior for detached HEAD.\n\nIt sounds like you want to know what branches point to the commit you\nare detached at?\n\n    git for-each-ref --format='%(refname:short)' --points-at=HEAD refs/heads/\n\n-- \nKristoffer Haugsbakk\n"},{"id":"518965","messageId":"580a4d79-841f-4731-88cb-f68fc27d9e8d@app.fastmail.com","threadId":"63529","inReplyTo":"FR0P281MB2879A89B0E1B775DB4B037749464A@FR0P281MB2879.DEUP281.PROD.OUTLOOK.COM","subject":"Re: Bug in git branch --show-current","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2025-05-27T08:36:18Z","receivedAt":"2025-05-27T08:36:39Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"Remember to reply-all on this list. Thanks.\n\nOn Tue, May 27, 2025, at 09:58, Ulrich Wittenberg wrote:\n> Well, the commit hat I am sitting on was made on a branch. The question\n> is: What ist he name oft he branch?\n\nYou say that this is a Jenkins job where it’s on detached HEAD.  Git\ndoesn’t record in the Git database itself what branch the user was on\nwhen the commit was made (if any since you can commit on detached HEAD).\nUnlike Mercurial (as I’ve heard, I haven’t used it), Git doesn’t store\nthat information.  A branch in Git points to a commit.\n\nBut the ephemeral reflog (git-reflog(1)) can record how a branch (and\nHEAD) was updated.  From that you can find out what branch the user was\non when a commit was made.  But the reflog is local only.\n\nBut I wonder if you really need this information.  I’ve never had a need\nfor it.  Git is not designed in such a way that makes querying this\ninformation simple.\n\n> I tried your command and it also return nothing.\n> All other commands also suddenly keep it Top Secret on what branch I am.\n> Only an interactive \"git log\" shows it in the first line, but if you\n> pipe that output into another command, this text also is suppressed.\n>\n> My next idea ist o dump the branch name (which the jenkins job knows)\n> into a file and continue from there...\n\nYou might want to describe\n\n• What commit Jenkins is on\n• Where the branch or branches of interests point to\n• How you expect branches to work\n"}]}