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

Re: bug? fetching from empty unnamed remote repos

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 12, 2017, 18:08 UTC
Message-ID
<xmqqink1nknk.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<b3d0d39fe9d443fd8202b8b055d31f86@exmbdft7.ad.twosigma.com>
David Turner <David.Turner@twosigma.com> writes:
Show 6 quoted lines
> $ git init empty-1
> $ git init empty-2 
> $ cd empty-1
> $ git fetch ../empty-2
> fatal: Couldn't find remote ref HEAD
> fatal: The remote end hung up unexpectedly

The current repository does not know anything about empty-2 repository. It does not have [remote "name"] section that points at ../empty-2 and it does not have a refspec to fetch.

Hence "git fetch ../empty-2" tries to fetch HEAD from that repository by default. It does not exist, and it fails.

Show 5 quoted lines
> But:
> $ git init empty-1
> $ git init empty-2 
> $ cd empty-1
> $ git remote add other ../empty-2

You told to your current repository to have [remote "other"] section, that points at ../empty-2 and fetch with refs/heads/*:refs/remotes/other/* as the refspec.

> $ git fetch other

Hence "git fetch other" tries to fetch refs/heads/* into refs/remotes/other/*; not having any matching source is not a crime---it is a simple noop.

> # this works

So there is nothing surprising about all of the above as far as I can see.

Previous: David Turner
Message 2 of 2 in “bug? fetching from empty unnamed remote repos”
  1. David TurnerJun 12, 2017
  2. Junio C HamanoJun 12, 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.