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

Re: "git fetch -p" incorrectly deletes branches

From
Jeff King <peff@peff.net>
Date
Jan 26, 2017, 21:18 UTC
Message-ID
<20170126211834.eplmjcohv3d4zsym@sigill.intra.peff.net>
In-Reply-To
<20170117060428.nanqz5lr4hi6dum6@reimardoeffinger.de>
On Tue, Jan 17, 2017 at 07:04:28AM +0100, Reimar Döffinger wrote:
Show 11 quoted lines
> Deletes refs/heads/test every second time when run repeatedly:
> 
> $ git fetch -p -v origin master:refs/heads/test
> From https://github.com/git/git
>  * [new branch]          master     -> test
>  = [up to date]          master     -> origin/master
> $ git fetch -p -v origin master:refs/heads/test
> From https://github.com/git/git
>  - [deleted]             (none)     -> test
>  = [up to date]          master     -> test
>  = [up to date]          master     -> origin/master

Hmm. It seems like the problem is that "-p" is saying "the other side does not have refs/heads/test; we must prune it". But I think it is probably nonsense to apply pruning to a non-wildcard refspec.

> Also note that this behaviour appears also when fetch.prune=yes
> is set in the config (instead of -p on the command-line),
> which makes it much less obvious and there is no option to turn
> of prune just for that command to work-around this.

There is a separate issue of whether it is sane to apply fetch.prune to a refspec given on the command line; I can imagine it as surprising, to say the least.

I think "--no-prune" would disable it, though.
-Peff
Previous: Reimar Döffinger
Message 2 of 2 in “"git fetch -p" incorrectly deletes branches”
  1. Reimar DöffingerJan 17, 2017
  2. Jeff KingJan 26, 2017

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.