Last active
December 26, 2018 09:43
-
-
Save fenying/7fb5cca492da6b7bdc82862597dbddfa to your computer and use it in GitHub Desktop.
Get the latest tag of git respository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Method 1, reference: https://stackoverflow.com/a/29497919 | |
git log --tags --simplify-by-decoration --pretty="format:%ci %d" | head -n 1 | grep -Po '(?<=tag: ).+?(?=,)' | |
# Method 2, reference: https://stackoverflow.com/questions/6269927/how-can-i-list-all-tags-in-my-git-repository-by-the-date-they-were-created#comment81585017_24830212 | |
git tag --sort=-creatordate | head -n 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment