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

[bug] docs claim git fetch --deepen doesn't fetch tags, but it does

From
TCTim Cuthbertson <tim@gfxmonk.net>
Date
Jun 1, 2022, 12:39 UTC
Message-ID
<CAC-LLDiu9D7Ea-HaAsR4GO9PVGAeXOc8aRoebCFLgDKow=hPTQ@mail.gmail.com>
The docs for git fetch `--depth` say:
> Tags for the deepened commits are not fetched.
And shallow.txt says:
> - If you deepen a history, you'd want to get the tags of the
> newly stored (but older!) commits. This does not work right now.

However it seems like this has been implemented, and the corresponding docs should instead declare that tags for the fetched commits are fetched. It certainly looks that way from my testing:

``` $ git --version git version 2.32.1 (Apple Git-133)

$ git clone --depth=1 https://github.com/git/git Cloning into 'git'... # < ... >

$ cd git

$ git describe --tags --always 1bcf4f6

$ git fetch --deepen 8
# < ... >
Unpacking objects: 100% (12/12), 9.02 KiB | 9.02 MiB/s, done.
From https://github.com/git/git
* [new tag] v2.31.3 -> v2.31.3
* [new tag] v2.32.1 -> v2.32.1
* [new tag] v2.32.2 -> v2.32.2
* [new tag] v2.33.2 -> v2.33.2
* [new tag] v2.33.3 -> v2.33.3
* [new tag] v2.34.1 -> v2.34.1
* [new tag] v2.34.2 -> v2.34.2
* [new tag] v2.34.3 -> v2.34.3
* [new tag] v2.35.1 -> v2.35.1
* [new tag] v2.35.2 -> v2.35.2
* [new tag] v2.35.3 -> v2.35.3
* [new tag] v2.36.0 -> v2.36.0

$ git describe --tags --always v2.35.3-35-g1bcf4f6 ```

(I get the same results using `git clone --depth` or `git fetch --depth`)

It'd be good to have someone who understands the code confirm this (and what version it was implemented, in case it's accidental, or doesn't always work as expected.

I found a stackoverflow from a couple years ago implying this didn't work at the time, though it doesn't say what git version they were using: https://stackoverflow.com/questions/56477321/can-i-make-git-fetch-a-repository-tag-list-without-actually-pulling-the-commit-d

Message 1 of 1 in “[bug] docs claim git fetch --deepen doesn't fetch tags, but it does”
  1. Tim CuthbertsonJun 1, 2022

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.