Gmane
Picon Picon Favicon Gravatar
From: Junio C Hamano <gitster <at> pobox.com>
Subject: Re: [BUG] git fetch --prune --tags origin deletes all remote branches origin/*
Newsgroups: gmane.comp.version-control.git
Date: 2010-08-25 23:52:10 GMT (1 year, 23 weeks, 6 days, 17 hours and 22 minutes ago)
Kevin Ballard <kevin <at> sb.org> writes:

> 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)