How can I decorate a git log with its nearest tag?

前端 未结 2 1542
闹比i
闹比i 2021-02-08 03:50

git log --decorate adds information about related refs to the log output:

commit 9e895ace5d82df8929b16f58e9f515f6d54ab82d (tag: v3.10-rc7)
Author: L         


        
2条回答
  •  再見小時候
    2021-02-08 04:33

    As you can see, older tag names are used as reference point rather than the point where the commit got merged.

    That should be possible... soon (git 1.8.4 July 2013):

    See commit e00dd1e9485c50f202cc97dfae19d510e108b565:

    describe: Add --first-parent option
    

    Only consider the first parent commit when walking the commit history.
    This is useful if you only wish to match tags on your branch after a merge.


    The OP Lekensteyn comments it (--first-parent) isn't enough:

    --first-parent does not show the tag where it got merged too.
    I just discovered that --contains can be used for that.
    See my answer for an even better solution, git name-rev.

    Note: git name-rev dates back from git0.99.9 (Oct. 2005!).

提交回复
热议问题