Reputation: 69
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?
Upvotes: 2
Views: 1885
Reputation: 67127
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 2.6.9
, git describe
will give you the following output:
2.6.9-<NUMCOMMITS>-g<CURRENTREV>
If your current branch points directly to 2.6.9
, NUMCOMMITS
and CURRENTREV
will not be printed and the command only yields 2.6.9
.
However, if you did some commits since 2.6.9
(e.g. 3), NUMCOMMITS
will be 3
and CURRENTREV
will be the 7 chars of the abbreviated last commit hash (e.g. 2597536
):
2.6.9-3-g2597536
Same could be achieved for unannotated tags using the --tags
switch:
git describe --tags
Upvotes: 3
Reputation: 1326746
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
Upvotes: 1