How can I display commit's position in the history relative to tags (and branches)?
I’m looking for a way to get information about where a commit occurred relative to tags (and branches if possible). Is there some kind of command or group of commands (if necessary, I can use any bash commands as well) that I could give a commit hash and receive a list of all tags (and branches) in order with the commit in the correct position relative to the other tags? For example, if
<commit-hash> occurred between
tag3, then the following command:
Would result in something like the following output:
branch1 tag1 tag2 <commit-hash> tag3 branch2 master
I tried using
git log to do this, but I’m really not sure where to start. Would this even be possible?
One Solution collect form web for “How can I display commit's position in the history relative to tags (and branches)?”
git describe --tags $rev will give you a short description (see the man page for details) of the tag immediately before the revision.
git describe --contains $rev will give you the first tag that contains the revision.
git rev-list --branches --tags $rev might be a useful place to start also. You might be able to get something like what you want by using some of the “History Simplification” arguments to that function. I’d try
--simplify-by-decoration first and then possibly
To control the output of
git rev-list you can use the
--format argument. Use
--format=%d to get the ref names (in an unfortunately annoying format however).