My organization is considering moving from SVN to Git. One argument against moving is as follows:

How do we do versioning?

We have an SDK distribution based on the NetBeans Platform. As the SVN revisions are simple numbers we can use them to extend the version numbers of our plugins and SDK builds. How do we handle this when we move to Git?

Possible solutions:


Using the build number from Hudson (Problem: you have to check Hudson to correlate that to an actual Git version)
Manually upping the version for nightly and stable (Problem: Learning curve, human error)


If someone else has encountered a similar problem and solved it, we'd love to hear how.

Use tags to mark commits with version numbers:

git tag -a v2.5 -m 'Version 2.5'


Push tags upstream—this is not done by default:

git push --tags


Then use the describe command:

git describe --tags --long


This gives you a string of the format:

v2.5-0-gdeadbee
^    ^ ^^
|    | ||
|    | |'-- SHA of HEAD (first seven chars)
|    | '-- "g" is for git
|    '---- number of commits since last tag
|
'--------- last tag

