Re: git fetch --prune fails with "fatal: bad object"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jun 08, 2024 at 02:02:52PM -0700, Fred Long wrote:

> >    git for-each-ref --format='%(refname)' refs/remotes/ |
> >    git cat-file --batch-check='%(objectname)' |
> >    perl -alne 'print "delete $F[0]" if $F[1] eq "missing"' |
> >    tee /dev/stderr |
> >    git update-ref --stdin
> > 
> Thanks. Here's what I have been using:
> 
> git fsck |& grep "invalid sha1 pointer" | (
>     while read err ref rest
>     do
>         ref=${ref%:}
>         echo got $ref, removing .git/$ref
>         rm .git/$ref
>     done
> )

Parsing fsck's errors should be OK, I think, but your "rm" won't be
reliable. If the ref is packed, then it needs to be removed from
.git/packed-refs, too. Calling "git update-ref -d $ref" should work,
even for a broken ref.

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux