Can git list the tags that occur between two particular commits?

This command efficiently lists all tags between commits commit1 and commit2 (not including commit1 itself).

git log --simplify-by-decoration --pretty=format:%D commit1..commit2 | \
    grep -o 'tag: [^,)]\+' | sed 's/^tag: //'

The git log ... command lists the branches and tags referencing each commit in the specified range. The subsequent commands parse out just the tags.


If you only wants the tag name list (in reverse chronological order) between commit1 and commit2, you can combine git log with xargs and git tag --points-at:

git log commit1..commit2 --simplify-by-decoration --format=format:%h | xargs -L1 git tag --points-at

You can use the git log command with these options:

git log tagA...tagB --decorate --simplify-by-decoration

--decorate displays the tag names next to the commit, and --simplify-by-decoration shows only commits that have been tagged.

Tags:

Git

Tags

Commit