Git垃圾收集似乎并没有完全奏效 [英] Git Garbage collection doesnt seem to fully work

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

问题描述



git count-objects -v -H

 警告:发现垃圾:./objects/pack/gc_7174754666377259454.idx_tmp 
警告:发现垃圾:./objects /pack/gc_7174754666377259454.pack_tmp
警告:发现垃圾:./objects/pack/pack-f5b13f50fe2e4d773028c51f547822e6f2fe720b.bitmap
count:0
size:0 bytes
in-pack:32986
包:1
大小包:44.14 MiB
修剪包:0
垃圾:3
大小垃圾:41.20 MiB

这对我意味着我的回购中有41个垃圾回收?



git gc --prune = now --aggressive

 计数对象:32986,完成。 
使用多达8个线程的增量压缩。
压缩对象:100%(31610/31610),完成。
写作对象:100%(32986/32986),完成。
总计32986(delta 23902),重用9080(delta 0)

再次计数对象我仍然有相同的输出

  size-garbage:41.20 MiB 

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

  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文件43,195,455字节
0 Dir(s)502,905,999,360字节free


解决方案

  C:\ Users \VonC\prog\git \ git> git log -Ssize-garbage | more 

这显示 size-garbage 输出已在 commit 1a20dd4 中引入对于git 1.8,NguyễnTháiNgọcDuy( pclouds ))。 3(2013年5月)


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



<中code> count-objects :报告垃圾文件占用多少磁盘空间



同时对松散的垃圾邮件而不是错误,因为
使用 report_garbage()函数在 count_objects()


垃圾清洁提示部分提及:


为了使回购大小最小化,您需要以下命令(这两个命令都不会完成整个工作)。

另请注意 a >重新包装,这表示您要盲目丢弃不可到达的对象而不是将它们保留为松散对象。




 git repack -adf#杀死包内垃圾
git prune#杀死松散垃圾

请重试 git count-ob在应用两个命令后应用-v -H




查看 git repack 手册页 a>, jthill 增加


我更喜欢大 - A 选项:



-a 相同,除非使用 -d
然后,前一包中的任何不可访问的对象变成松散的,未包装的对象,而不是放在旧包中。





Linus Torvalds认为 -f gc - 攻击性被滥用 -
如此之多,以至于他建议将文档翻译成

(in 2007年)

-f 用于 - no-reuse-delta


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

  git repack -Ad#杀死垃圾桶
git prune#杀死垃圾桶


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

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:\Users\VonC\prog\git\git>git log -Ssize-garbage|more

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: disk space consumed by garbage files, in KiB

count-objects: report how much disk space taken by garbage files

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

This garbage cleaning tip section mentions:

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

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


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

I prefer the big-A option:

"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 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天全站免登陆