gittagsgit-loggit-tag

Get the two most recent git tags (and the log between them)


I am looking for a git command that would show me the git log between the two most recent tags in the current branch.

I.e. if the two most recent tags are build_341 and build_342, then I would want to end up with the output of git log build_341..build_342

I know that I can get the most recent tag using git describe --abbrev=0, but I don't know how to show the second most recent tag.


Solution

  • Well, it's possible to get the second most recent tag using:

    git describe --abbrev=0 $(git describe --abbrev=0)^
    

    So I can get a log between the two most recent tags using:

    git log $(git describe --abbrev=0 $(git describe --abbrev=0)^)..$(git describe --abbrev=0)
    

    Not pretty, but it seems to work (as long as your shell supports $() command substiution). Other answers are welcome.