# Retrieve version-string on shallow clone

3 messages from 2019-09-01 to 2019-09-02. Participants: Reino Wijnsma, Philip Oakley, Jeff King.
Thread: https://gitlist.dev/t/51783

## Reino Wijnsma, 2019-09-01 11:07

Subject: Retrieve version-string on shallow clone
Message-ID: <26d7f32e-2df5-ce39-cd20-8cd82dc8587c@xs4all.nl>
URL: https://gitlist.dev/e/26d7f32e-2df5-ce39-cd20-8cd82dc8587c%40xs4all.nl

```
Hello git@vger.kernel.org,

Two days ago I started https://github.com/mstorsjo/fdk-aac/issues/107, asking how to retrieve the fdk-aac version-string on a shallow clone.
My question was of course not fdk-aac related, so Martin Storsjö suggested I'd try here. It basicly comes down to this:

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.
I'm not an expert git user, so I was wondering if anyone could tell what my options are here.
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?
As another option I was thinking; maybe it's possible to do git describe --tags on the remote repo?

Thanks!

-- Reino

```

## Philip Oakley, 2019-09-02 15:52

Subject: Re: Retrieve version-string on shallow clone
Message-ID: <26794b96-8627-0d73-c548-91b0ea7fde83@iee.email>
URL: https://gitlist.dev/e/26794b96-8627-0d73-c548-91b0ea7fde83%40iee.email
In-Reply-To: <26d7f32e-2df5-ce39-cd20-8cd82dc8587c@xs4all.nl>

```
Hi Reino

On 01/09/2019 12:07, Reino Wijnsma wrote:
> Hello git@vger.kernel.org,
>
> Two days ago I started https://github.com/mstorsjo/fdk-aac/issues/107, asking how to retrieve the fdk-aac version-string on a shallow clone.
> My question was of course not fdk-aac related, so Martin Storsjö suggested I'd try here. It basicly comes down to this:
>
> 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.
> I'm not an expert git user, so I was wondering if anyone could tell what my options are here.
> 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?
> As another option I was thinking; maybe it's possible to do git describe --tags on the remote repo?
>
This is most likely a mental model problem.

If you only have a depth = 1 level clone, then there is no history 
available locally to use from which to describe almost anything.
Even if you had all the tags (without the actual commits they tagged) 
you still don't have that history upon which to describe them.

Start by getting a bit more history depth, then see if you need to fetch 
some of the tags (or at least any specific tags of interest).

Philip


```

## Jeff King, 2019-09-02 15:54

Subject: Re: Retrieve version-string on shallow clone
Message-ID: <20190902155440.GE18593@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20190902155440.GE18593%40sigill.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:

> 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

```
