# problem with updating a shallow clone via a branch fetch

4 messages from 2011-03-01 to 2012-01-13. Participants: Rick Bradley, Junio C Hamano, Rahul Jain.
Thread: https://gitlist.dev/t/26626

## Rick Bradley, 2011-03-01 00:12

Subject: problem with updating a shallow clone via a branch fetch
Message-ID: <AANLkTinx01bzzLKk=DfyEvfSz8Hun-YqzJfEDpX7gNSS@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinx01bzzLKk%3DDfyEvfSz8Hun-YqzJfEDpX7gNSS%40mail.gmail.com

```
So I have a git repo that is shallow cloned:

  % git clone --depth 1 <repo url>

Sometimes (very rarely), when I do a branch fetch to update that
repository I get an error:

 % git fetch origin +refs/head/<branch>:refs/remotes/origin/<branch>

fatal: did not find object for shallow <hash>

There are only 3 mentions of this error on google, none of which are
enlightening.  The error is being emitted by receive_need(void) in
upload-pack.c.  The commit in question exists in the named branch in
the upstream repository, and I'm not aware that anything sketchy
(forced pushes, etc.) has gone on.  I'm going to continue to research
the history of the repo and the deployment, but I can't seem to get
any insight on what the error actually means (i.e., what conditions
would cause this error to be triggered).

Any help is appreciated,
Rick

```

## Junio C Hamano, 2011-03-01 00:25

Subject: Re: problem with updating a shallow clone via a branch fetch
Message-ID: <7vtyfng00i.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vtyfng00i.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTinx01bzzLKk=DfyEvfSz8Hun-YqzJfEDpX7gNSS@mail.gmail.com>

```
Rick Bradley <rick@rickbradley.com> writes:

> So I have a git repo that is shallow cloned:
>
>   % git clone --depth 1 <repo url>
>
> Sometimes (very rarely), when I do a branch fetch to update that
> repository I get an error:
>
>  % git fetch origin +refs/head/<branch>:refs/remotes/origin/<branch>
>
> fatal: did not find object for shallow <hash>

The message comes from the repository you are fetching from.  When you
fetch from a shallow clone, the fetch process on your end tells the other
side what commits your incomplete history ends at, and if the other end
does not have any of these commits, you get that message.  So the only
case (unless there is a bug---and I don't think this codepath is heavily
exercised so it is very possible there are bugs) you would see that
message is if the other side rewound the branch and then later garbage
collection lost the commit.

```

## Rick Bradley, 2011-03-01 02:07

Subject: Re: problem with updating a shallow clone via a branch fetch
Message-ID: <AANLkTimSRG+UkD1vJszUf+3j0nV+_pPWSE3N2Dy9SfTa@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimSRG%2BUkD1vJszUf%2B3j0nV%2B_pPWSE3N2Dy9SfTa%40mail.gmail.com
In-Reply-To: <7vtyfng00i.fsf@alter.siamese.dyndns.org>

```
Junio,
Thanks for the assistance.  I'll be looking in the direction of what
could have caused sanity problems in the upstream repo.  If it happens
again and we can collect more tea leaves (this checkout was cleaned up
before I could get a copy of it to do further diagnosis :-/) I'll see
what else we can find out.

Rick

On Mon, Feb 28, 2011 at 6:25 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Rick Bradley <rick@rickbradley.com> writes:
>
>> So I have a git repo that is shallow cloned:
>>
>>   % git clone --depth 1 <repo url>
>>
>> Sometimes (very rarely), when I do a branch fetch to update that
>> repository I get an error:
>>
>>  % git fetch origin +refs/head/<branch>:refs/remotes/origin/<branch>
>>
>> fatal: did not find object for shallow <hash>
>
> The message comes from the repository you are fetching from.  When you
> fetch from a shallow clone, the fetch process on your end tells the other
> side what commits your incomplete history ends at, and if the other end
> does not have any of these commits, you get that message.  So the only
> case (unless there is a bug---and I don't think this codepath is heavily
> exercised so it is very possible there are bugs) you would see that
> message is if the other side rewound the branch and then later garbage
> collection lost the commit.
>

```

## Rahul Jain, 2012-01-13 04:09

Subject: Re: problem with updating a shallow clone via a branch fetch
Message-ID: <loom.20120113T050744-134@post.gmane.org>
URL: https://gitlist.dev/e/loom.20120113T050744-134%40post.gmane.org
In-Reply-To: <AANLkTimSRG+UkD1vJszUf+3j0nV+_pPWSE3N2Dy9SfTa@mail.gmail.com>

```
I was also getting the same error. I went to .git/shallow file and deleted 
<hash>. After that everything was working fine.

```
