Git 垃圾收集似乎无法完全正常工作 [英] Git Garbage collection doesnt seem to fully work

查看:17
本文介绍了Git 垃圾收集似乎无法完全正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点困惑如何彻底清理我的垃圾......

I'm a little confused as how to completely clean out my garbage...

git count-objects -v -H

warning: garbage found: ./objects/pack/gc_7174754666377259454.idx_tmp
warning: garbage found: ./objects/pack/gc_7174754666377259454.pack_tmp
warning: garbage found: ./objects/pack/pack-f5b13f50fe2e4d773028c51f547822e6f2fe720b.bitmap
count: 0
size: 0 bytes
in-pack: 32986
packs: 1
size-pack: 44.14 MiB
prune-packable: 0
garbage: 3
size-garbage: 41.20 MiB

所以这对我来说意味着我的回购中有 41 兆的垃圾?

So that implies to me I have 41 megs of garbage in my repo?

git gc --prune=now --aggressive

Counting objects: 32986, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (31610/31610), done.
Writing objects: 100% (32986/32986), done.
Total 32986 (delta 23902), reused 9080 (delta 0)

当我再次运行计数对象时,我仍然有相同的输出

And when I run count objects again i still have the same output with

    size-garbage: 41.20 MiB

我只是手动删除垃圾文件吗?至少有一个是相当丰满的.

Do I just manually delete the garbage files? At least one is quite plump at the very least.

12/02/2014  02:06 PM                 0 gc_7174754666377259454.idx_tmp
12/02/2014  02:06 PM        43,195,455 gc_7174754666377259454.pack_tmp
               2 File(s)     43,195,455 bytes
               0 Dir(s)  502,905,999,360 bytes free

推荐答案

C:UsersVonCproggitgit>git log -Ssize-garbage|more

这表明 size-garbage 输出已被引入 commit 1a20dd4 Nguyễn Thái Ngọc Duy (pclouds) 为 git 1.8.3 (2013 年 5 月)

This show the size-garbage output has been introduced in commit 1a20dd4 by Nguyễn Thái Ngọc Duy (pclouds) for git 1.8.3 (May 2013)

size-garbage:垃圾文件占用的磁盘空间,单位KiB

size-garbage: disk space consumed by garbage files, in KiB

同时在 loose 垃圾 上发出警告,而不是由于以下原因导致的错误在 count_objects()

Also issue warnings on loose garbages instead of errors as a result of using report_garbage() function in count_objects()

这个垃圾清理技巧部分提到:

要将 repo 大小降至最低限度,您需要以下两个命令(这两个命令本身都不能完成整个工作).
另请注意repack"上的小写a",它表示您希望盲目丢弃无法访问的对象,而不是将它们保留为松散的对象.

To bring the repo size down the bare minimum, you need both the following commands (neither command by itself does the whole job).
Also Note the lowercase "a" on the "repack", which says you want to blindly discard unreachable objects instead of keeping them as loose objects.

git repack -adf     # kills in-pack garbage
git prune           # kills loose garbage

所以在应用 both 命令之后再试一次 git count-objects -v -H.

So try again the git count-objects -v -H after applying both commands.

查看 git repack 手册页jthill 添加 在评论中:

Looking at the git repack man page, jthill adds in the comments:

我更喜欢 big-A 选项:

I prefer the big-A option:

"与 -a 相同,除非使用 -d.
然后,前一个包中的任何无法访问的对象都会变成松散的、未打包的对象,而不是留在旧包中."

"Same as -a, unless -d is used.
Then any unreachable objects in a previous pack become loose, unpacked objects, instead of being left in the old pack."

Linus Torvalds 认为 -fgc--aggressive 被过度使用了 -- 这么多,所以他建议抽出它的文档.
(2007 年)
(-f 用于 --no-reuse-delta)

Linus Torvalds argues that -f like gc's --aggressive is much overused -- so much so he suggested yanking the documentation for it.
(in 2007)
(-f is for --no-reuse-delta)

这意味着更有效的组合可能是:

That means a more efficient combination might be:

git repack -Ad      # kills in-pack garbage
git prune           # kills loose garbage

这篇关于Git 垃圾收集似乎无法完全正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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