Borek Borek - 1 month ago 15
Git Question

How to use `git describe` on repos without tags?

For most of our repos, we use

git describe --tags
to print a version number like
v1.0.4-14-g2414721
. However, this fails if the repo doesn't have any tags yet.

Is there a flag of
git describe
or something similar that would work around this?

Answer

git-describe offers --always to give a fallback option. If you have any tags those are used, otherwise just the most recent commit id.