L
Lawrence D'Oliveiro
Discovered yet another nifty Git feature while looking through the docs.
Build scripts often try to automatically determine some kind of revision
number to include with the version info when building a piece of software.
With Subversion, you can use “svn info†to get a revision number that
increments with every commit, that you can use for that.
With Git, there is no real equivalent, since it has no sequence numbers for
anything, every object being identified by its SHA-1 hash, with no sensible
ordering at all.
But if you have tagged some prior revision, the command “git describe --
tags†will generate a string of the form
<tag>-<nr revisions since>-g<part of current revision hash>
For example, looking at the current dvdauthor source tree, the command
returns this
0.7.0-18-g6143744
which means it has been 18 commits since the one I released (and tagged) as
“0.7.0â€, and the hash for the last commit begins with 6143744.
Exercise for the reader: what happens if you don’t specify “--tags�
Build scripts often try to automatically determine some kind of revision
number to include with the version info when building a piece of software.
With Subversion, you can use “svn info†to get a revision number that
increments with every commit, that you can use for that.
With Git, there is no real equivalent, since it has no sequence numbers for
anything, every object being identified by its SHA-1 hash, with no sensible
ordering at all.
But if you have tagged some prior revision, the command “git describe --
tags†will generate a string of the form
<tag>-<nr revisions since>-g<part of current revision hash>
For example, looking at the current dvdauthor source tree, the command
returns this
0.7.0-18-g6143744
which means it has been 18 commits since the one I released (and tagged) as
“0.7.0â€, and the hash for the last commit begins with 6143744.
Exercise for the reader: what happens if you don’t specify “--tags�