I keep a bare git repository (call it mylibs) on an external drive, in which I have a dev branch. I recently did:
git clone /media/extdrive/mylibs; cd mylibs
git checkout dev
And was surprised to receive:
fatal: unable to read tree 03e99624424e6bd337ee16122567338751abef05
Running git fsck
in the bare repository, reports:
Checking object directories: 100% (256/256), done.
broken link from tree 892d4fd7eb30964eb33de9ac707b4b0edbc919a5
to tree 03e99624424e6bd337ee16122567338751abef05
missing tree 03e99624424e6bd337ee16122567338751abef05
dangling blob e94d7824aca487641c11ff8312915fae5ef62cbe
dangling blob 27afaaaa0f9979b4963d86bb1e5ddc3fe0d50d8b
dangling blob e3d72157044f5b6808881025102764726f672d61
I know this topic has been discussed to death (ex: 1, 2, 3), but the answers which I have found all seem rather complicated, and a bit over my head. More importantly, none seemed to work (certainly because of something I was doing wrong, not because the answers were incorrect).
I have this repo cloned all over the place, and while I have no backups of the bare repository, the working clones are all up-to-date and do have the 03/e99624424e6bd337ee16122567338751abef05
object.
My question is: can I simply copy the 03/e99624424e6bd337ee16122567338751abef05
object directly from a working clone into the .git/objects
directory of the bare repo on my external drive, or is that an incomplete procedure?
i.e. is this sufficient?
# assuming I'm in a working copy
cp .git/objects/03/e99624424e6bd337ee16122567338751abef05 \
/media/extdrive/mylibs/.git/objects/03/.
The path /media/extdrive/mylibs/.git/objects/03/
already exists and contains a few other objects.
Notes:
- I made a copy of the bare repository, and tested the above and it seemed to work fine. But I want to be sure that I'm not missing something.
- The .git/objects/pack/ directory is empty in the bare repository, and in all of my working clones. I don't know if that's indicative of anything, but it precludes use of some of the solutions that I have found.