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?

  • How to get rid of Git submodules untracked status?
  • How to synchronize a GitHub repository and multiple Gists
  • Any Way I Can Easily Merge Git Branches Created in CVS2Git Migration?
  • How to transfer multiply commits from one branch to another using git?
  • SourceTree delete all local branches under a specific directory
  • Setup Git without SSH
  • How do I get last commit date from git repository?
  • how to config git to overwrite non text file instead of version controlled it?
  • How to create reusable Durandal widgets
  • Show complete files as they would exist in the git index
  • Using multiple Git repos inside folder with same top level parent directory?
  • SourceTree 1.6.14 cannot find Git 2.4.0 installation on Windows
  • 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 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 
    

    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
    
    Git Baby is a git and github fan, let's start git clone.