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

Re: Tags auto fetched by "git fetch origin" but not "git fetch origin main"

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Aug 29, 2024, 22:22 UTC
Message-ID
<ZtD0kJU_OdBBktZ2@tapette.crustytoothpaste.net>
In-Reply-To
<xmqqy14ft36l.fsf@gitster.g>
On 2024-08-29 at 21:44:02, Junio C Hamano wrote:
Show 7 quoted lines
> "brian m. carlson" <sandals@crustytoothpaste.net> writes:
> 
> > If you want tags nonetheless, you can use the `--tags` option, which
> > should fetch tags in addition to the refspec provided.
> 
> But doesn't that grab _all_ tags, not only the relevant tags that
> point into the history leading to the commits being fetched?
It's not clear to me.  The description says this:
  By default, any tag that points into the histories being fetched is
  also fetched; the effect is to fetch tags that point at branches that
  you are interested in. This default behavior can be changed by using
  the --tags or --no-tags options or by configuring
  remote.<name>.tagOpt. By using a refspec that fetches tags explicitly,
  you can fetch tags that do not point into branches you are interested
  in as well.

That implies that `--tags` or `--no-tags` simply changes whether that limited set of tags is fetched.

But the `--tags` option says this:
  Fetch all tags from the remote (i.e., fetch remote tags refs/tags/* into
  local tags with the same name), in addition to whatever else would
  otherwise be fetched. Using this option alone does not subject tags to
  pruning, even if --prune is used (though tags may be pruned anyway if
  they are also the destination of an explicit refspec; see --prune).
That implies that all tags are fetched.

I think we need somebody to test things and clarify the documentation. (I'm not volunteering because I have a lot of things on my plate right now.)

In addition, it might be useful to add a `--relevant-tags` option or some such that simply fetches the relevant tags when arbitrary refspecs are specified. If someone felt super interested, they could even make an additional generic option over other refspecs (I can imagine something like GitHub's refs/pull might be interesting for users).

-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 6 in “Tags auto fetched by "git fetch origin" but not "git fetch origin main"”
  1. Yukai ChouAug 28, 2024
  2. brian m. carlsonAug 29, 2024
  3. Junio C HamanoAug 29, 2024
  4. brian m. carlsonAug 29, 2024
  5. Junio C HamanoAug 29, 2024
  6. Yukai ChouAug 29, 2024

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.