Fix Git "object not found" for good

Lanbo picture Lanbo · Mar 12, 2013 · Viewed 11.5k times · Source

From one pull to the next, every git pull on the server ends up in this:

$ git pull
remote: Counting objects: 53, done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 32 (delta 19), reused 0 (delta 0)
Unpacking objects: 100% (32/32), done.
error: unable to find 71682baccff823caa21420b16dd231c6b9c1b133
fatal: object 71682baccff823caa21420b16dd231c6b9c1b133 not found

Same with git fetch. I could solve this for one pull by copying the file .git/object/71/682baccff823caa21420b16dd231c6b9c1b133 to the server, but after some more pulls, the error was still there, every time with the newest commit object on the branch.

How can this happen? And how can I fix it for good?

A complete git clone is not a good solution since this repository is on a running server project and has more files around without git control.

Is it possible to clone into a new directory and then copy the .git directory into the old folder? Or is there any other solution without touching the directories?

Answer

Lanbo picture Lanbo · Mar 24, 2013

I could fix the problem by

  1. Try to fetch (with the error)
  2. Copy the object file over like above
  3. git merge with the commit of the missing object file.

Now it seems solved, the error does not appear again.