git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Retrieve version-string on shallow clone

From
Jeff King <peff@peff.net>
Date
Sep 2, 2019, 15:54 UTC
Message-ID
<20190902155440.GE18593@sigill.intra.peff.net>
In-Reply-To
<26d7f32e-2df5-ce39-cd20-8cd82dc8587c@xs4all.nl>
On Sun, Sep 01, 2019 at 01:07:44PM +0200, Reino Wijnsma wrote:
Show 12 quoted lines
> git clone https://github.com/mstorsjo/fdk-aac.git
> [...]
> 
> git describe --tags
> v2.0.0-185-gcc5c85d
> 
> git clone --depth 1 https://github.com/mstorsjo/fdk-aac.git
> 
> git describe --tags
> fatal: No names found, cannot describe anything.
> 
> The tags get lost while doing a shallow clone.

Right. As noted elsewhere in the thread, this is the expected behavior of Git. But what you want is perfectly reasonable; there's just not a good way to do it yet.

> I'd figure one of these options would be to clone everything from tag
> v2.0.0 onward, but if so how would I do that?

I don't think there's a good way to do this. But I also think it's not quite what you want, as you'd end up transferring a lot of extra data (and deeper shallow fetches load the server more, as we can't use reachability bitmaps, and we have to do extra on-the-fly delta compression).

> As another option I was thinking; maybe it's possible to do git
> describe --tags on the remote repo?

This seems like it's more directly what you want, and doesn't have a lot of downsides. There's no way to trigger this within Git's protocols. If it's an ssh server you control, you can of course run git-describe yourself on the server. For a hosting site like GitHub, you'd need support from the host's non-Git API. I don't _think_ anything like that exists right now in GitHub's API, though.

-Peff
Previous: Philip Oakley
Message 3 of 3 in “Retrieve version-string on shallow clone”
  1. Reino WijnsmaSep 1, 2019
  2. Philip OakleySep 2, 2019
  3. Jeff KingSep 2, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.