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

Re: Is there a quick way to identify commits that reference missing trees or blobs?

From
Clemens Buchacher <drizzd@aon.at>
Date
Jul 25, 2011, 22:34 UTC
Message-ID
<20110725223449.GA25560@toss.lan>
In-Reply-To
<CAH3AnroyfeGOo_23nHKhLjxEnP_qEMi7as1UjXEFjjuVOckBjw@mail.gmail.com>
On Sun, Jul 24, 2011 at 02:48:20AM +1000, Jon Seymour wrote:
>
> I was wondering if there is a quick way to identify commits that
> reference missing trees or blobs as identified by git fsck?

The following command has served me well for this purpose. I apply it to each ref in git-for-each-ref:

$ git rev-list --objects $ref | git cat-file --batch-check

It may not be the fastest way to do it, but it did the trick for me. I then simply deleted any broken refs using git update-ref -d $ref, even if the tip of the branch was still intact. I could have tried to salvage some history from those refs, but I had a backup and at that point I just wanted to continue working.

hth, Clemens

Previous: Jon SeymourNext: Clemens Buchacher
Message 2 of 5 in “Is there a quick way to identify commits that reference missing trees or blobs?”
  1. Jon SeymourJul 23, 2011
  2. Clemens BuchacherJul 25, 2011
  3. Clemens BuchacherJul 25, 2011
  4. Jon SeymourJul 26, 2011
  5. Jon SeymourJul 26, 2011

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.