[Development] gerrit : using branches

Matthew Woehlke mwoehlke.floss at gmail.com
Tue Apr 5 18:04:35 CEST 2016


On 2016-04-04 08:49, René J.V. Bertin wrote:
> [...] there's no way to obtain the branch from a given commit?

There is `git name-rev`, but it may or may not work or give you the
"best" answer. At least it should give you *a* branch name if a SHA is
the tip of a local branch. I'm not sure offhand what it does if multiple
branches name the same SHA¹, or how it works with tags or non-local
branches. Note that this can give answers like `master~2`, i.e. it can
in at least some cases name commits that *aren't* the tip of a branch.

(¹ You should at least get *a* name. I don't know if you'll get all
possible names, or if it will just pick one.)

You should also look at gitk, which will show you the graph, including
all names (tags as well as branches) of named SHA's. (The `--decorate`
option to `git log` does this also.)

-- 
Matthew




More information about the Development mailing list