Last Updated: February 25, 2016
·
1.951K
· leifhanack

git describe --tags to version number your artefacts

Releasing an artefact must be reliable. Best you tag your code. Using git it is as easy as git tag -a 1.3. If you are lucky and don't have to use maven's release plugin, you should obviously use gradle;) With git describe --tags you will receive a perfect version number.

$> git tag -a 1.3
$> git describe --tags
1.3
$> git commit -am "some changes"
$> git commit -am "some more changes"
..
$> git describe --tags
1.3-17-gc161601 

git describe --tags gives you either the current tag (1.3) or a meaningful SNAPSHOT version: 1.3-17-gc161601.

Meaningful? Sure! It is <yourLastTag>-<numberCommitsAfterTagging>-g<sha1KeyOfLastCommit>.