How to get previous tag name?

Or between the last two tags

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

Alternative solution with any sorting you like to get the next tag after the current one:

git tag --sort=-creatordate | grep -A 1 second | tail -n 1
  1. git tag --sort=-creatordate prints all tags from newest to oldest by creator date: "first second third fourth". Choose sorting option wisely.
  2. grep -A 1 second filter only "second" and one following line after it, i.e "third".
  3. tail -n 1 prints one last line from "second third" and we have finally get the "third".

git describe --abbrev=0 second^

Tags:

Git