I'd like to get the number of commits of my git repository, a bit like SVN revision numbers.
The goal is to use it as a unique, incrementing build number.
I currently do like that, on Unix/Cygwin/msysGit:
git log --pretty=format:'' | wc -l
To get a commit count for a revision (
master, a commit hash):
git rev-list --count <revision>
To get the commit count across all branches:
git rev-list --all --count
I recommend against using this for build identifier, but if you must, it's probably best to use the count for the branch you're building against. That way the same revision will always have the same number. If you use the count for all branches, activity on other branches could change the number.