git: dangling blobs

╄→尐↘猪︶ㄣ 提交于 2019-11-28 07:54:30
Waynn Lue

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"
Daniel

I was really impatient and used:

git gc --prune="0 days"

Whenever you add a file to the index, the content of that file are added to Git's object database as a blob. When you then reset/rm --cached that file, the blobs will still exist (they will be garbage collected the next time you run gc)

However, when those files are part of a commit and you decide later to reset history, then the old commits are still reachable from Git's reflog and will only be garbage collected after a period of time (usually a month, iirc). Those objects should not show up as dangling though, since they are still referenced from the reflog.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!