I need to write an autoupdate script for our project. I have everything, except that I can't determine the name of the latest received tag. I tried with git describe, but it tells me the latest checked out tag. I don't need that of course, I have to get the next reachable tag to checkout. Any idea?
Asked
Active
Viewed 421 times
1 Answers
2
Try this:
git describe --tags --abbrev=0 branch_name
to retrieve the name of the latest tag searching back from the tip of the desired branch, rather than HEAD
(the current checkout).
That is, if your auto-update script has fetched origin master
, you can do
git describe --tags --abbrev=0 origin/master
Note: --abbrev=0
makes describe
return only the tag name, without a sha1 at the end. --tags
makes describe return the latest annotated or unannotated tag. See git-describe(1) for a full discussion of the possible options.

shelhamer
- 29,752
- 2
- 30
- 33
-
sorry, I completely forgot about this question somehow :( only one addition: first I need to do a `git fetch origin master` and then I can use `git describe --tags --abrev=0 origin/master` origin master without the slash wouldn't work the way I need. – r1pp3rj4ck Jan 22 '13 at 10:56