Reputation: 3278
Using https://github.com/google/glog as an example. The latest release is 0.3.5.
After searching hours on stackoverflow and google, I am not able to find a correct answer.
git describe
shows
v0.3.3-147-gb3695ee
and
git describe --tags
shows
v0.3.4-133-gb3695ee
and
git describe --tags `git rev-list --tags --max-count=1`
shows
v0.3.5
What command should I type in order to get
v0.3.5-41-gb3695ee
Upvotes: 3
Views: 5414
Reputation: 8656
I think your command use is correct, and it's more of a repo/branch issue.
Briefly, from the describe documentation:
The command finds the most recent tag that is reachable from a commit. If the tag points to the commit, then only the tag is shown. Otherwise, it suffixes the tag name with the number of additional commits on top of the tagged object and the abbreviated object name of the most recent commit.
By default (without --all or --tags) git describe only shows annotated tags. For more information about creating annotated tags see the -a and -s options to git-tag.
So if the desired tag isn't being shown using git describe
, we can assume it's either:
To show non-annotated tags, we can used git describe --tags
. Since this seems to give us a different tag, but not the one you're after, we can probably conclude that the tag you're interested in either doesn't exist, or is not reachable from the current branch.
I cloned the repo in question and ran git tag --list
which does show a selection of tags including 0.3.3
, 0.3.4
, and 0.3.5
.
So it seems the tag exists, but must not be on the master
branch.
We can confirm this with git branch --contains <commit>
, where <commit>
will be 0.3.5
. If you haven't yet cloned any remote branches, this will give you no results.
We can run git branch -r --contains <commit>
to check the remote branches, which gives the output origin/v035
. It looks like the tag we're after is only reachable on the remote origin/v035
branch.
If we checkout this branch locally, and run git describe --tags
, we will get the output v0.3.5
, we don't see the suffix described by the docs, because the tag points at the current commit (tip of the branch).
Upvotes: 4