Wayne Werner Wayne Werner - 1 year ago 61
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 Source

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


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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download