# bug? fetching from empty unnamed remote repos

2 messages from 2017-06-12 to 2017-06-12. Participants: David Turner, Junio C Hamano.
Thread: https://gitlist.dev/t/46160

## David Turner, 2017-06-12 17:50

Subject: bug? fetching from empty unnamed remote repos
Message-ID: <b3d0d39fe9d443fd8202b8b055d31f86@exmbdft7.ad.twosigma.com>
URL: https://gitlist.dev/e/b3d0d39fe9d443fd8202b8b055d31f86%40exmbdft7.ad.twosigma.com

```
$ 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

But:
$ git init empty-1
$ git init empty-2 
$ cd empty-1
$ git remote add other ../empty-2
$ git fetch other
# this works

I haven't spent a lot of time looking into the code, because we can use the second option.  But it does seem weird.

```

## Junio C Hamano, 2017-06-12 18:08

Subject: Re: bug? fetching from empty unnamed remote repos
Message-ID: <xmqqink1nknk.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqink1nknk.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <b3d0d39fe9d443fd8202b8b055d31f86@exmbdft7.ad.twosigma.com>

```
David Turner <David.Turner@twosigma.com> writes:

> $ 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.

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


```
