How do I get the Git commit count?
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.
This command returns count of commits grouped by committers:
git shortlog -s
14 John lennon 9 Janis Joplin
You may want to know that the
-s argument is the contraction form of
git rev-list HEAD --count
git rev-list <commit> :
List commits that are reachable by following the parent links from the given commit (in this case, HEAD).
--count : Print a number stating how many commits would have been listed, and suppress all other output.
git shortlog is one way.