Getting a build number via git

A commit count can be used as a build number for a revision (e.g. HEAD, master, a commit hash):

$ git rev-list --count <revision>

To check the commit count across all branches:

$ git rev-list --all --count