git:晃来晃去的斑点 [英] git: dangling blobs

查看:137
本文介绍了git:晃来晃去的斑点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在我的存储库上运行了 git fsck --lost-found



我预计会看到一些悬而未决的提交,其中我重置了 HEAD



然而,我惊讶地发现可能发生了数千条悬而未决的blob消息。



我不相信我的存储库有什么问题,但我很好奇导致这些晃动斑点的原因是什么?只有两个人在存储库上工作,我们没有做任何不寻常的事情。



我不认为它们是由旧版本的文件被替换为新文件,因为git需要保存在两个blob中,以便它可以显示历史记录。



想一想,有一次我们添加了一个非常大的目录(成千上万的文件)错误的项目,然后将其删除。这可能是所有晃来晃去的斑点的来源?



只是寻找这个神秘的洞察力。

解决方案

上次我看了这个,我偶然发现了 this线程,特别是这个部分:


你也可以用包装中的悬挂对象结束。当这个包被
重新打包时,这些对象将被放宽,然后根据上述规则最终过期
。不过,我相信gc不会总是重新包装旧包装;它会制造新的包装,直到你有很多包装,
,然后把它们全部结合起来(至少这就是gc --auto会做的事情;我
不记得是否只是git gc遵循相同的规则)。

所以这是正常的行为,并且最终收集到,我相信。 b
$ b

编辑:通过Daniel,您可以立即通过运行收集它

  git gc  - prune =0 days


I recently ran git fsck --lost-found on my repository.

I expected to see a couple dangling commits, where I had reset HEAD.

However, I was surprised to see likely over several thousand dangling blob messages.

I don't believe anything is wrong with my repository, but I'm curious as to what causes these dangling blobs? There's only two people working on the repository, and we haven't done anything out of the ordinary.

I wouldn't think they were created by an older version of a file being replaced by a new one, since git would need to hold onto both blobs so it can display history.

Come to think of it, at one point we did add a VERY large directory (thousands of files) to the project by mistake and then remove it. Might this be the source of all the dangling blobs?

Just looking for insight into this mystery.

解决方案

Last time I looked at this I stumbled across this thread, specifically this part:

You can also end up with dangling objects in packs. When that pack is repacked, those objects will be loosened, and then eventually expired under the rule mentioned above. However, I believe gc will not always repack old packs; it will make new packs until you have a lot of packs, and then combine them all (at least that is what "gc --auto" will do; I don't recall whether just "git gc" follows the same rule).

So it's normal behavior, and does get collected eventually, I believe.

edit: Per Daniel, you can immediately collect it by running

git gc --prune="0 days"

这篇关于git:晃来晃去的斑点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆