Wayne Werner Wayne Werner - 1 month ago 5
Git Question

Is there a way to get the number of additional commits in git without awk?

If I've got some tags in git I can use this:

git describe --tags | awk -F- '{ print $2 }'


To display the number of commits since my last tag. Is there a way to get this number just using git commands?

Answer

Git dark-voodoo:

git rev-list --count `git describe --abbrev=0 --tags` HEAD

or maybe slightly changed into (haven't Git, can't test, writing from memory)

git rev-list --count `git describe --abbrev=0 --tags`..HEAD

Note:

git log <RANGE> --pretty=oneline | wc -l

will work also, but a lot slower, than rev-list