I'm running git 1.6.4.2. Garbage collection is failing saying "error: unable to find <SHA1>
".
我正在运行git 1.6.4.2。垃圾收集失败说“错误:无法找到
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,并且我无法恢复blob文件。似乎运行“git add”和“git commit”的2个脚本同时运行并且设法相互干扰,因此一个文件提交的文件比另一个版本更新,旧版本的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.
所以我现在要做的就是回滚我的存储库以取出引用引用丢失的blob的树的提交。
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 reset”以回退到duff提交的父级。而且我知道分支在其他地方合并了,所以我也重新分配了那个分支。据我所知,duff commit / tree / blob没有被任何东西引用。但是,如果我运行git prune --expire = now然后是git gc,那么我仍然会收到有关丢失对象的错误。
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?
所以我的问题是:如何查询git数据库以查找包含duff blob id的每个树对象?然后我如何找出导致git prune保留它的原因?
Tricky!!
整蛊!
Thanks Kevin
谢谢凯文
2 个解决方案
#1
11
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 repo中删除一个blob-git prune没有修剪我要回收的东西,因为reflog仍然指的是它。运行
git reflog expire --expire=now --all
fixed that. Also, the referenced post gives a mechanism for running git lstree
on every commit to find the referenced blob.
修好了。此外,引用的帖子提供了一种机制,用于在每次提交时运行git lstree以查找引用的blob。
#2
3
I had the same problem (missing blob) and the solution with
我有同样的问题(缺少blob)和解决方案
git reflog expire --expire=now --all
didn't do the trick. I found my solution here : https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F
没有做到这一点。我在这里找到了我的解决方案:https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F
This simple line
这条简单的路线
git hash-object -w <file>
Fixed the missing blob.
修复了丢失的blob。
Hope this helps.
希望这可以帮助。
#1
11
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 repo中删除一个blob-git prune没有修剪我要回收的东西,因为reflog仍然指的是它。运行
git reflog expire --expire=now --all
fixed that. Also, the referenced post gives a mechanism for running git lstree
on every commit to find the referenced blob.
修好了。此外,引用的帖子提供了一种机制,用于在每次提交时运行git lstree以查找引用的blob。
#2
3
I had the same problem (missing blob) and the solution with
我有同样的问题(缺少blob)和解决方案
git reflog expire --expire=now --all
didn't do the trick. I found my solution here : https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F
没有做到这一点。我在这里找到了我的解决方案:https://git.wiki.kernel.org/index.php/GitFaq#How_to_fix_a_broken_repository.3F
This simple line
这条简单的路线
git hash-object -w <file>
Fixed the missing blob.
修复了丢失的blob。
Hope this helps.
希望这可以帮助。