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

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

From
FLFred Long <fred_long@fastmail.fm>
Date
Jun 13, 2024, 03:29 UTC
Message-ID
<fbe6ae6c-a89b-ae71-2474-10ac3afd0766@fastmail.fm>
In-Reply-To
<20240611073134.GE3248245@coredump.intra.peff.net>
On 6/11/2024 12:31 AM, Jeff King wrote:
Show 24 quoted lines
> 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

Yes, and your solution is better than a newbie like me could have figured out, which is why I have been arguing for a simple documented command that people like me can run.

Previous: Jeff King
Message 16 of 16 in “git fetch --prune fails with "fatal: bad object"”
  1. Curley JoeMay 31, 2024
  2. Junio C HamanoMay 31, 2024
  3. rsbecker@nexbridge.comMay 31, 2024
  4. Junio C HamanoJun 1, 2024
  5. Jeff KingJun 4, 2024
  6. Junio C HamanoJun 4, 2024
  7. Jeff KingJun 5, 2024
  8. Fred LongJun 4, 2024
  9. Jeff KingJun 5, 2024
  10. Fred LongJun 5, 2024
  11. Jeff KingJun 6, 2024
  12. Fred LongJun 6, 2024
  13. Jeff KingJun 8, 2024
  14. Fred LongJun 8, 2024
  15. Jeff KingJun 11, 2024
  16. Fred LongJun 13, 2024

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.