# What is the default refspec for fetch?

6 messages from 2014-11-07 to 2014-11-11. Participants: Christian Halstrick, Jeff King, Jakub Narębski, Junio C Hamano.
Thread: https://gitlist.dev/t/37897

## Christian Halstrick, 2014-11-07 15:31

Subject: What is the default refspec for fetch?
Message-ID: <CAENte7inZ5fm2SzNPq=HNPKnPco9tM4T_es5Dphnpbia-uiLdg@mail.gmail.com>
URL: https://gitlist.dev/e/CAENte7inZ5fm2SzNPq%3DHNPKnPco9tM4T_es5Dphnpbia-uiLdg%40mail.gmail.com

```
Hi,

In a repo where no remote.<name>.fetch config parameter is set what
should a "git fetch" do? My experiments let me think it's
"HEAD:FETCH_HEAD". Right?

I came to this question after finding out that when I clone repos in
bare mode then they don't have and explicit remote.<name>.fetch in
their config. But a "git fetch" sometimes updated "something".

Ciao
  Chris

```

## Jeff King, 2014-11-08 10:52

Subject: Re: What is the default refspec for fetch?
Message-ID: <20141108105221.GA20750@peff.net>
URL: https://gitlist.dev/e/20141108105221.GA20750%40peff.net
In-Reply-To: <CAENte7inZ5fm2SzNPq=HNPKnPco9tM4T_es5Dphnpbia-uiLdg@mail.gmail.com>

```
On Fri, Nov 07, 2014 at 04:31:08PM +0100, Christian Halstrick wrote:

> In a repo where no remote.<name>.fetch config parameter is set what
> should a "git fetch" do? My experiments let me think it's
> "HEAD:FETCH_HEAD". Right?

Basically, yes. We always write FETCH_HEAD, regardless of the refspec.
We choose "HEAD" if no other refspec was provided. So it is really more
like

  git fetch $remote HEAD

This is what makes one-off bare-url pulls work, like:

  git pull git://...

It runs fetch under the hood, which writes into FETCH_HEAD, and then we
merge that.

-Peff

```

## Jakub Narębski, 2014-11-08 14:35

Subject: Re: What is the default refspec for fetch?
Message-ID: <545E2A2D.2040205@gmail.com>
URL: https://gitlist.dev/e/545E2A2D.2040205%40gmail.com
In-Reply-To: <20141108105221.GA20750@peff.net>

```
W dniu 2014-11-08 11:52, Jeff King pisze:
> On Fri, Nov 07, 2014 at 04:31:08PM +0100, Christian Halstrick wrote:
>
>> In a repo where no remote.<name>.fetch config parameter is set what
>> should a "git fetch" do? My experiments let me think it's
>> "HEAD:FETCH_HEAD". Right?
>
> Basically, yes. We always write FETCH_HEAD, regardless of the refspec.
> We choose "HEAD" if no other refspec was provided. So it is really more
> like
>
>    git fetch $remote HEAD
>
> This is what makes one-off bare-url pulls work, like:
>
>    git pull git://...
>
> It runs fetch under the hood, which writes into FETCH_HEAD, and then we
> merge that.

Actually FETCH_HEAD consists of multiple lines, one per ref...
but only top ref is merged.

-- 
Jakub Narębski

```

## Junio C Hamano, 2014-11-09 17:23

Subject: Re: What is the default refspec for fetch?
Message-ID: <xmqq7fz4e18x.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq7fz4e18x.fsf%40gitster.dls.corp.google.com
In-Reply-To: <545E2A2D.2040205@gmail.com>

```
Jakub Narębski <jnareb@gmail.com> writes:

> W dniu 2014-11-08 11:52, Jeff King pisze:
>> On Fri, Nov 07, 2014 at 04:31:08PM +0100, Christian Halstrick wrote:
>>
>>> In a repo where no remote.<name>.fetch config parameter is set what
>>> should a "git fetch" do? My experiments let me think it's
>>> "HEAD:FETCH_HEAD". Right?
>>
>> Basically, yes. We always write FETCH_HEAD, regardless of the refspec.
>> We choose "HEAD" if no other refspec was provided. So it is really more
>> like
>>
>>    git fetch $remote HEAD
>>
>> This is what makes one-off bare-url pulls work, like:
>>
>>    git pull git://...
>>
>> It runs fetch under the hood, which writes into FETCH_HEAD, and then we
>> merge that.
>
> Actually FETCH_HEAD consists of multiple lines, one per ref...
> but only top ref is merged.

Incorrect in that "only top" is misinformation, and irrelevant in
the context of discussing the "what is fetched in a one-off fetch".

```

## Christian Halstrick, 2014-11-11 23:01

Subject: Re: What is the default refspec for fetch?
Message-ID: <CAENte7ggGPgNktH_ArVsjN2yDLADHQApDCzWbQLo_bbCiduk6w@mail.gmail.com>
URL: https://gitlist.dev/e/CAENte7ggGPgNktH_ArVsjN2yDLADHQApDCzWbQLo_bbCiduk6w%40mail.gmail.com
In-Reply-To: <xmqq7fz4e18x.fsf@gitster.dls.corp.google.com>

```
ok, thanks. Then I'll teach JGit to fetch at least "HEAD" if nothing
is configured and nothing explicitly specified as refspec.
Ciao
  Chris


On Sun, Nov 9, 2014 at 6:23 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Jakub Narębski <jnareb@gmail.com> writes:
>
>> W dniu 2014-11-08 11:52, Jeff King pisze:
>>> On Fri, Nov 07, 2014 at 04:31:08PM +0100, Christian Halstrick wrote:
>>>
>>>> In a repo where no remote.<name>.fetch config parameter is set what
>>>> should a "git fetch" do? My experiments let me think it's
>>>> "HEAD:FETCH_HEAD". Right?
>>>
>>> Basically, yes. We always write FETCH_HEAD, regardless of the refspec.
>>> We choose "HEAD" if no other refspec was provided. So it is really more
>>> like
>>>
>>>    git fetch $remote HEAD
>>>
>>> This is what makes one-off bare-url pulls work, like:
>>>
>>>    git pull git://...
>>>
>>> It runs fetch under the hood, which writes into FETCH_HEAD, and then we
>>> merge that.
>>
>> Actually FETCH_HEAD consists of multiple lines, one per ref...
>> but only top ref is merged.
>
> Incorrect in that "only top" is misinformation, and irrelevant in
> the context of discussing the "what is fetched in a one-off fetch".

```

## Junio C Hamano, 2014-11-11 23:04

Subject: Re: What is the default refspec for fetch?
Message-ID: <xmqqegt95ofm.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqegt95ofm.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CAENte7ggGPgNktH_ArVsjN2yDLADHQApDCzWbQLo_bbCiduk6w@mail.gmail.com>

```
Christian Halstrick <christian.halstrick@gmail.com> writes:

> ok, thanks. Then I'll teach JGit to fetch at least "HEAD" if nothing
> is configured and nothing explicitly specified as refspec.

Sounds like a sensible thing to do to match what JGit does to what
we did from the time immemorial ;-)

Thanks.

```
