gpt4 book ai didi

Git 垃圾收集似乎没有完全起作用

转载 作者:IT王子 更新时间:2023-10-29 01:27:35 28 4
gpt4 key购买 nike

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

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 兆垃圾?

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)

当我再次运行 count objects 时,我仍然有相同的输出

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

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

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()

garbage cleaning tip section提及:

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

因此,在应用两个 命令后再次尝试 git count-objects -v -H


查看 git repack man page , jthill添加 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)

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

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

关于Git 垃圾收集似乎没有完全起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27257399/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com