我想测量/计数 git 中的对象,看看我是否接近自动打包,我认为这可以通过计算 .git/objects/... 中的文件来轻松完成,但我不确定。
故事是这样的:
这几天,每当我推送到我的 git 仓库时,它都会自动打包。 (git repo 保存在 USB 内存棒上,因此自动打包非常慢,我在 30 分钟左右后取消了它)
这是同样的问题:
What does "Auto packing the repository for optimum performance" mean?
I'm having a problem with my git repo. For the last couple of days whenever I do a push to the server I get this message: "Auto packing the repository for optimum performance"
在同一个线程中我找到了解决方案:
To disable for one project:
cd your_project_dir
git config gc.auto 0
To disable globally:
git config --global gc.auto 0
这解决了我对那个特定 repo 的问题...
...但是我的内存棒上还有更多的 git 存储库,我想知道一种方法来衡量我的其他 git 存储库是否接近自动打包
我发现:
Why does git run auto-packing on every push to our repo?
Git decides whether to auto gc based on two criteria:
Are there too many packs? (Literally, are there more than 50 files with .idx in .git/objects/pack?)
Are there too many loose objects? (Literally, are there more than 27 files in .git/objects/17?)
我的问题几乎已经得到解答,但我只是想确认我的理解是否正确:如何测量/计算松散的物体以查看我是否接近自动包装? -- 是否(如上述答案中所建议的那样)从字面上计算 .git/objects/17 中的文件并与 27 的硬限制进行比较,
——或者它可能正在计算 .git/objects/01、.../02、.../03 等中的所有文件,并将平均值与 git config global 中定义的软限制进行比较?
-- 即使它是微不足道的,是否有一个 git 命令可以对 .git/objects/17 中的对象进行计数? -- 是否有返回硬限制 27 的 git 命令?
最佳答案
答案在 Why does git run auto-packing on every push to our repo?仍然有效。正如您在最新版本的 git (2.10.2) 的源代码中看到的那样,this is the function need_to_gc
决定 gc 是否运行。
- 是选项
gc.auto
设置为 0 还是负数? - 有没有
too_many_packs
: 是选项gc.autopacklimit
(默认 50)正且小于包数(*.idx
中的文件.git/objects/pack
)? - 有没有
too_many_loose_objects
: 是选项gc.auto
(默认 6700)正数,是.git/objects/17
中松散物体的数量(它只在这个目录中查找;不计算全部并取平均值或最大值或类似的值)大于({gc.auto} + 255)/256)
?
这就是数字 27 的来源:它是 (6700 + 255)/256 的底数。您可以通过增加 gc.auto
来增加它.你可以用 git 命令 git config --get gc.auto
得到这个数字 27 的等价物。但这只有在明确设置该选项时才有效。
关于git - 在 Git 中测量/计数对象以查看我是否接近自动打包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39191119/