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

Re: [BUG] git fetch --prune --tags origin deletes all remote branches origin/*

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 25, 2010, 23:52 UTC
Message-ID
<7vsk22ntcl.fsf@alter.siamese.dyndns.org>
In-Reply-To
<84CF7907-4493-4110-A852-B949BAE0214C@sb.org>
Kevin Ballard <kevin@sb.org> writes:
Show 5 quoted lines
> Running the simple command `git fetch --prune --tags origin` will delete
> every single remote branch refs/remotes/origin/*, with the sole
> exception of refs/remotes/origin/HEAD. This is wildly unexpected
> behavior. This was reproduced on the tip of the next branch, with
> version git version 1.7.2.2.440.g49ea7.

I suspect "--prune --tags" behaved like that from the very beginning of the appearance of "--prune", and also it is not limited to --tags. With this:

    [remote "origin"]
        url = $over_there
        fetch = refs/heads/master:refs/heads/origin
        fetch = refs/heads/next:refs/heads/next
"git fetch --prune origin master" would probably remove your local next.

get_stale_heads() seems to assume that it has the list of all existing refs from the remote side available to make its decision. Unless the fetch is done using a list of refs configured with remote.<name>.fetch, I do not think that assumption holds.

  f2ef607 (remote: refactor some logic into get_stale_heads(), 2009-11-10)
  f360d84 (builtin-fetch: add --prune option, 2009-11-10)
Previous: Kevin BallardNext: Jay Soffian
Message 2 of 3 in “[BUG] git fetch --prune --tags origin deletes all remote branches origin/*”
  1. Kevin BallardAug 25, 2010
  2. Junio C HamanoAug 25, 2010
  3. Jay SoffianAug 26, 2010

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.