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

Re: My git repo is broken, how to fix it ?

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Feb 28, 2007, 16:19 UTC
Message-ID
<Pine.LNX.4.64.0702280802150.12485@woody.linux-foundation.org>
In-Reply-To
<200702281754.42383.litvinov2004@gmail.com>
On Wed, 28 Feb 2007, Alexander Litvinov wrote:
Show 11 quoted lines
>
> >  - replace any broken and/or missing objects
> >
> >    This is the challenging part. Sometimes (hopefully often!) you can find
> >    the missing objects in other copies of the repositories. At other
> >    times, you may need to try to find the data some other way (for
> >    example, maybe your checked-out copy contains the file content that
> >    when hashed will be the missing object?).
> 
> Thanks for answer. I have found this blob in cloned repo. I just copy it into 
> objects subdir and repack repo again. fsck works without any errors.
Good to hear.
It would probably be good to
 - try to figure out why things got corrupted in the first place.
   In particular, we should probably check our (my) assumption that the 
   file rename on cygwin is atomic. Your comment that you use ^C a lot 
   makes me worry that something basically caused an incomplete write or 
   other thing to happen..
   To be more precise, git will actually start off trying to do a "link + 
   unlink" pair, because that is the safest thing to do on a UNIX 
   filesystem: if the linked target already exists, we won't overwrite it 
   (and the git data consistency rules have always been: honor existing 
   data over new one, and *never* change anything that has already been 
   written).
   But I would not be shocked to hear that the "link + unlink" sequence 
   ends up being emulated under cygwin as a "copy + delete" due to lack of 
   hardlinks or something.
   Also, even if the link fails, and git then falls back to "rename()" 
   (since some filesystems don't do hardlinks at all, or limit them to one 
   particular directory), I would _still_ not be totally surprised if the 
   rename got emulated as a copy/delete for some strange Windows reason.
   There are other possibilities for corruption, of course: just plain 
   disk corruption, or (again) some other subtle cygwin emulation or 
   Windows issue could bite us. 
 - Even under UNIX, I'm not entirely sure about http/ftp/rsync transfers. 
   rsync in particular doesn't check anything at all, but last I looked, 
   the http fetcher was also doing things like checking the integrity of 
   the object *after* it had already moved it to its final resting place 
   (which is again unsafe with ^C).
   In general, I strongly suggest that people use the "native git" 
   pack-transfers. The "dumb protocol" transfers are called "dumb" for a 
   reason..
 - It would probably be good to write up the "How to recover" thing, 
   regardless of why any corruption happens. It doesn't matter if you're 
   under UNIX and using native protocols, and just being careful as hell: 
   disks get corrupted, sh*t happens, alpha-particles in the wrong place 
   do bad things to memory cells. And bugs _are_ inevitable, even if 
   we've been pretty damn good about these things.
   So it's important for people to know what the limits on corruption are, 
   and tell people that regardless of how stable the git data structures 
   are, if you care about your data, you need to have things in multiple 
   places (and no, RAID is _not_ the answer either, even if it can be a 
   small _part_ of doing things well).
Anybody?
		Linus
Previous: Alexander LitvinovNext: Alex Riesen
Message 4 of 28 in “My git repo is broken, how to fix it ?”
  1. Alexander LitvinovFeb 28, 2007
  2. Linus TorvaldsFeb 28, 2007
  3. Alexander LitvinovFeb 28, 2007
  4. Linus TorvaldsFeb 28, 2007
  5. Alex RiesenFeb 28, 2007
  6. Alexander LitvinovMar 19, 2007
  7. Linus TorvaldsMar 19, 2007
  8. Linus TorvaldsMar 20, 2007
  9. Alexander LitvinovMar 20, 2007
  10. Junio C HamanoMar 20, 2007
  11. Nicolas PitreMar 20, 2007
  12. Linus TorvaldsMar 22, 2007
  13. Nicolas PitreMar 22, 2007
  14. Linus TorvaldsMar 22, 2007
  15. Linus TorvaldsMar 22, 2007
  16. Linus TorvaldsMar 22, 2007
  17. Nicolas PitreMar 22, 2007
  18. Linus TorvaldsMar 22, 2007
  19. Nicolas PitreMar 22, 2007
  20. Jeff KingMar 22, 2007
  21. Linus TorvaldsMar 23, 2007
  22. Bill LearMar 23, 2007
  23. Jeff KingMar 23, 2007
  24. git-apply: Do not free the wrong buffer when we convert the data for writeoutJunio C Hamano, Mar 22, 2007
  25. Linus TorvaldsMar 22, 2007
  26. Alexander LitvinovMar 23, 2007
  27. Alexander LitvinovMar 23, 2007
  28. Johannes SixtMar 22, 2007

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.