Using Git describe without tags

Viewed 8169

I have a repository that gives me only a hash when I run git describe. I did not know until today that it does this because of the --always option (which is what I was using) since that repository has no tags. I have another repository with lots of tags.

How can I use git describe to exclude tags and just give me a hash? I want to have all of the other functionality of git describe in case I need to use the other features, such as dirty marking; I just want to exclude tags. Is this possible, or are tags the central feature of describe?

The help page does seem to indicate that, but I just want to be sure. I use this in an Ant build.xml file, so I'm trying to keep this simple.

3 Answers

Since the usual intent of one of these outputs from git describe is to provide a human-readable but exact-commit-specifying ID

That is what official git describe --long does have to do, according to Git 2.20

See commit 55f6bce, commit 6271d94, commit c263279 (19 Sep 2018) by Frederick Eaton (``).
(Merged by Junio C Hamano -- gitster -- in commit fb468f0, 16 Oct 2018)

git-describe.1: clarify that "human readable" is also git-readable

The caption uses the term "human readable", but the DESCRIPTION did not explain this in context.

The man page now includes:

The result is a "human-readable" object name which can also be used to identify the commit to other git commands.

Related