What\'s the simplest way to get the most recent tag in Git?
git tag a HEAD
git tag b HEAD^^
git tag c HEAD^
git tag
output:
git log --tags --no-walk --pretty="format:%d" | sed 2q | sed 's/[()]//g' | sed s/,[^,]*$// | sed 's ...... '
IF YOU NEED MORE THAN ONE LAST TAG
(git describe --tags sometimes gives wrong hashes, i dont know why, but for me --max-count 2 doesnt work)
this is how you can get list with latest 2 tag names in reverse chronological order, works perfectly on git 1.8.4. For earlier versions of git(like 1.7.*), there is no "tag: " string in output - just delete last sed call
If you want more than 2 latest tags - change this "sed 2q" to "sed 5q" or whatever you need
Then you can easily parse every tag name to variable or so.