4 ms·
You can try to git fsck in case that identifies the missing object. But I’m not sure there’s any ready made command to identify through which path a missing obj
by masklinn 3y ago
You can try to git fsck in case that identifies the missing object. But I’m not sure there’s any ready made command to identify through which path a missing object is reached.
It could actually be the reflog. Pruning the reflog then running “git gc —prune=now” might do the trick.
- drewg123 3y agoThank you. I've tried git fsck in the past, and it complains about the missing object as well. And I just tried "git gc —prune=now", and sadly it still fails the same way. I'm afraid I'm going to have to bite the bullet and clean up my 30 or so worktrees and re-clone the repo, and re-create the worktrees.
- williamcotton 3y agoTry a grep for that missing hash in the fatal message you posted and point it at a commit/object that does exist or just delete that line/file and see if that fixes it!
- drewg123 3y agoThis is more or less what I've been trying to do for quite a while. How do I grep for it? And once I do that, how can I "point it at a commit/object that does exist ?"
- williamcotton 3y agoIf it's a ref somewhere then it'll just be a string of the hash deadbeef style. Just open the file up and change it to another commit hash or just delete the ref completely. Try something like: grep -r "1cae71a9" ./.git/ And see if it comes up somewhere. My guess is that it's a ref for some old branch pointing at a commit that isn't around.
- Denvercoder9 3y agoThat won't work, as loose objects are stored zlib-compressed in .git, and packed objects can be stored in a delta format. You'd need something like this: git cat-file --unordered --batch-check='%(objectname)' --batch-all-objects | xargs -n1 -- git cat-file -p | grep 1cae71a9d5b24991c0d632b45186ca8a250e5d52
- drewg123 3y agoThank you! This has been running for several hours now. If this allows me to fix it, I'll be very grateful. I've been delaying re-rooting all those worktrees for 6mo or more.. :)
- pcthrowaway 3y agoYou might be able to recreate the git history without that object (or commit). Look into commands like filter-branch. I'd be surprised if there's not a way to recover from this situation