Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@fenying
Last active December 26, 2018 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fenying/7fb5cca492da6b7bdc82862597dbddfa to your computer and use it in GitHub Desktop.
Save fenying/7fb5cca492da6b7bdc82862597dbddfa to your computer and use it in GitHub Desktop.
Get the latest tag of git respository
#!/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