Personal web page: Emmanuel Branlard

Retrieve git version number, branch and revision

A unique git revision can be obtained using the short hash as follow:

git rev-parse --short HEAD       

To get a nice version number, the following command can be used

git describe --dirty=-dev        
This command ads "-dev" at the end of the revision to indicate that the repository is not clean. To use the above command it's necessary to had added an annotated tag:

git tag -a 1.0

The current git branch can be obtained using the following command:

git rev-parse --abbrev-ref HEAD