Determine latest received git tag
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 nex开发者_开发技巧t reachable tag to checkout. Any idea?
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.
精彩评论