Git - 如何从一个丢失的blob恢复 [英] Git - how to recover from a missing blob
问题描述
我运行git 1.6.4.2。垃圾收集失败说错误:无法找到< SHA1>
。
I'm running git 1.6.4.2. Garbage collection is failing saying "error: unable to find <SHA1>
".
确定缺少的对象是一个blob,并且没有办法,我可以得到blob文件回来。看来,运行git add和git commit的2个脚本同时运行,并且设法彼此干扰,使得一个提交的文件比另一个更新的版本,旧版本的Blob消失了。
I've managed to determine that the missing object is a blob, and there is no way that I can get the blob file back. It seems that 2 scripts that run "git add" and "git commit" were running at the same time and managed to interfere with each other so that one committed a newer version of a file than the other, and the older version's blob vanished.
所以我现在想做的是回滚我的仓库,取出指向丢失的blob的树的提交。
So what I'm trying to do now is roll back my repository to take out the commit that refers to the tree that refers to the missing blob.
我知道提交的哪个分支,所以我对它运行git reset来回滚到duff提交的父级。我知道分支合并到别的地方,所以我也绕过那个分支。所以据我所知,duff提交/ tree / blob不被任何引用。但是如果我运行git prune --expire = now,然后git gc,然后我仍然得到一个关于丢失的对象的错误。
I know which branch the commit was on, so I ran "git reset" on it to rewind to the parent of the duff commit. And I know that the branch was merged somewhere else, so I rewound that branch too. So as far as I know, the duff commit/tree/blob are not referenced by anything. But if I run git prune --expire=now followed by git gc then I still get an error about the missing object.
所以我的问题是这样:查询git数据库以查找包含duff blob id的每个树对象?然后如何找到导致git prune保留它的原因?
So my question is this: how can I query the git database to find every tree object that contains the duff blob id? And how do I then find out what is causing git prune to retain it?
Tricky !!
Tricky!!
Kevin
Thanks Kevin
推荐答案
更多的挖掘结果后,我的问题回答这里:如何从git repo中删除blob - git prune
不是修剪我的东西伤口回来,因为reflog仍然指的是。正在运行
After a bit more digging it turns out that my question is answered here: How to delete a blob from git repo - git prune
wasn't pruning the stuff I'd wound back because the reflog was still referring to it. Running
git reflog expire --expire=now --all
修复了。此外,引用的文章给出了在每次提交时运行 git lstree
的机制,以找到引用的blob。
fixed that. Also, the referenced post gives a mechanism for running git lstree
on every commit to find the referenced blob.
这篇关于Git - 如何从一个丢失的blob恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!