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, 21:32 UTC
Message-ID
<ZtDo--AY43-bPTHG@tapette.crustytoothpaste.net>
In-Reply-To
<CAEg0tHRbGBBq7i78bTSfws_WZO=2W7xuDwiT2qFA5iOza8qDDA@mail.gmail.com>
On 2024-08-28 at 23:23:57, Yukai Chou wrote:
> In using `git fetch [<options>] [<repository> [<refspec>…]]`,
> - when a branch is specified as <refspec>, no tags are fetched automatically;
> - when no <refspec>s are specified, tags are fetched automatically.

Yes, this is expected. Tags are refs, and when you specify no refspec, you're asking for the default behaviour, which usually involves fetching tags. But when you specify a refspec, you are saying, "I want you to fetch this, and only this; don't fetch anything else."

For example, if I say, `git fetch origin refs/heads/main:refs/heads/main`, it would be very unexpected for it to fetch tags as well; I only wanted it to fetch the main branch. In fact, I might be explicitly relying on it not affecting any other refs.

If you want tags nonetheless, you can use the `--tags` option, which should fetch tags in addition to the refspec provided.

-- 
brian m. carlson (they/them or he/him)
Toronto, Ontario, CA
Previous: Yukai ChouNext: Junio C Hamano
Message 2 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.