How do I show the commit position in history relative to tags (and branches)?

I am looking for a way to get information about where the commit happened with respect to tags (and branches if possible). Is there some command or group of commands (I can use any bash if needed ) that I can give a hash of the commit and get a list of all tags (and branches) so that the commit is in the correct position relative to the other tags? For example, if it <commit-hash>

happened between tag2

and tag3

, then the following command:

[command(s)] <commit-hash>

      

Something like the following output will appear:

branch1
tag1
tag2
<commit-hash>
tag3
branch2
master

      

I tried using git log

for this, but I'm really not sure where to start. Is it possible?

+3


source to share


1 answer


git describe --tags $rev

will give you a short description (see the man page for details) of the tag just before the revision.

git describe --contains $rev

will give you the first tag containing the revision.



git rev-list --branches --tags $rev

can be a useful place to start. You could get something like what you want by using some Simplify History arguments to this function. I'll try first --simplify-by-decoration

and then maybe --dense

.

git rev-list

You can use an argument to control the output --format

. Use --format=%d

to get the names of the links (in the case of an unfortunately annoying format).

+4


source







All Articles