We are working on a versioning system based on git tags.
While git describe
is great, we would prefer commands that output the three elements of git describe seperately (latest tag, commits since tag, commitId) e.g. TAG
12
gff9fd30
. We managed getting the commitId with git rev-parse HEAD
, but don't know if there are any commands for only getting the latest tag and the commits since that tag.
Of course it would be possible to split the output at hyphens, but if there is a cleaner solution, we would prefer it.
Thanks for any hints!
CodePudding user response:
Latest tag in the current branch:
git describe --tags --abbrev=0
(Found in https://stackoverflow.com/a/7261049/7976758, search: https://stackoverflow.com/search?q=[git] latest tag)
Count commits since a commit:
git rev-list --count <revision>..
(Please note ..
; https://stackoverflow.com/a/4061706/7976758, https://stackoverflow.com/search?q=[git] count commits).
Overall:
git rev-list --count $(git describe --tags --abbrev=0)..
Or
lasttag=$(git describe --tags --abbrev=0)
git rev-list --count $lasttag..
CodePudding user response:
only getting the latest tag
git describe --tags --abbrev=0
commits since that tag
git log LATEST_TAG..HEAD
, you can use --pretty
to format the logs.