I want to be able to pass anything to a git command (maybe its a SHA, maybe it’s just something like “origin/master” or “devel/epxerimental” etc.) and git tells me the ref path of the branch that the passed something lives in, e.g.
<git_command> 0dc27819b8e9 => output: refs/heads/master
<git_command> xyz/test => output: refs/remotes/xyz/master
...
I’ve been looking at git show or git log or git rev-parse and apart from --pretty=format:%d I couldn’t find anything.
(--pretty=format:%d output is quite strange with lotsa free space and empty lines and sometimes more than one ref paths are on one line bunched together).
There has to be a better way?
Thanks for reading.
Andre
There is no fixed information which would record such a data, because SHA1 are not associated at all time with a ref path.
Branches can moves, be renamed or deleted, while the SHA1 will still be stored (except if it is not referenced by any ref pattern, it will eventually be pruned)
That being said:
comes pretty close to what yout want:
A lot of options are available for
git show-refand will allow you to:The OP adds:
One other plumbing command that can help would be
git name-rev:As Jefromi mentions in the comments, a porcelain command would be
git branch --contain: