How to determine latest production release from a git master branch?
I am still a newbie on git. When I did a git clone … on any packages, it mostly downloads from the master branch.
My understanding is a master branch should contain both development and release codes.
If so, is it possible to find out the latest (production) release version from the downloaded master branch?
2 Solutions collect form web for “How to determine latest production release from a git master branch?”
If every release is marked with an annotated tag,
git describe is what you need (cite from man page):
git-describe – Show the most recent tag that is reachable from a commit
If your last released version is for example
git describe will give you the following output:
If your current branch points directly to
CURRENTREV will not be printed and the command only yields
However, if you did some commits since
2.6.9 (e.g. 3),
NUMCOMMITS will be
CURRENTREV will be the 7 chars of the abbreviated last commit hash (e.g.
Same could be achieved for unannotated tags using the
git describe --tags
The OP precises in the comments that “release version” isn’t about having binaries (deliveries) in the repo, but getting the versions which are used to produced delivery.
git tag alone is not well suite, because the order isn’t always pertinent.
However, as i explained in “How to sort git tags?”, this would give the right order (with git 2.0+)
git tag -l --sort=refname "v*" # or git tag -l --sort=version:refname "v*" v17 v16 ... v9 ... v1