Typical output of git-describe
looks like
some-tag-32-gf31f980
where some-tag
is a tag name, 32
means that the described commit is 32 commits after the commit with that tag, and gf31f980
means that the commit ID is uniquely abbreviated to f31f980
.
My question is about the g
in gf31f980
. Why is it there? My first thought was that it is inserted to disambiguate parsing of the output of git-describe
. But I can't think of any case in which it actually helps to have it. For example, the 32
component might be omitted, and there is no way to know that the output above describes a commit 32 commits after the tag some-tag
, rather than the commit at the tag some-tag-32
. But the g
doesn't help with this.
A regex match to extract just the commit ID can search for /-g([0-9a-f]+)$/
. There is no easy way to simplify this; you can't do /-g(.*)$/
for example because that might erroneously match a g
in the tag name. Without the g
you could still do /-([0-9a-f]+)$/
, so the g
isn't helping you there. Non-regex parsing processes will behave similarly.
The g
is generated explicitly; the relevant source code (around line 240 of builtin/describe.c
) is:
static void show_suffix(int depth, const unsigned char *sha1) { printf("-%d-g%s", depth, find_unique_abbrev(sha1, abbrev)); }
It's hard to search for information about this, because the relevant term, g
, is a stopword.
What's the g
for?
Commit IDs are unique SHA-1 hashes that are created whenever a new commit is recorded. If you specify a commit ID when you add a repository, Domino will always pull the state of the repository specified by that commit in a detached HEAD state.
The `git describe` command finds the most recent tag that is reachable from a commit. If the tag is on the current commit, then only the tag is shown. Otherwise, it shows the tag name appended with the number of additional commits and the abbreviated SHA of the current commit.
If you are unsure of the value to type: In a different web browser tab, go to your GitHub dashboard . In Your repositories, choose the repository name that contains the target commit. In the list of commits, find and copy the commit ID that refers to the revision in the repository.
Jesse Luehrs immediately pointed out on Twitter that this question is answered in the git-describe
man page:
The "g" prefix stands for "git" and is used to allow describing the version of a software depending on the SCM the software is managed with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With