I want to be able to roll back to a previous git tag without having to know what the current tag is or what the previous tag is.
I know how to get the latest tag:
git describe --abbrev=0 --tags
but how would I get the tag right before it?
I couldn’t find any resources online for doing this, so here is what I found to work:
git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`
The subcommand gets the hash of one recent tag. The
--skip=1 means the “latest” tag will be skipped and the “previous” tag to the latest will be returned.
If current tag is
1.1.5, the previous tag number returned would be
Answered By – Kevin Jantzer