停止 git gc --aggressive,这是一件坏事吗?

发布于 2024-11-08 17:54:51 字数 202 浏览 1 评论 0原文

我正在一个非常大的存储库(apx 100 GB)上运行 git gc --aggressive 。它从两天前的晚上开始运行,几个小时后,它一直卡在:“压缩对象:99%(76496/76777)”

如果我 Ctrl-C 这个过程,有什么后果?我的仓库会无法使用吗?我的直觉告诉我不会,但我想听听一些意见。谢谢!

I am running a git gc --aggressive on a very large repo (apx 100 gb). It's been running since two nights ago, and as of a couple hours, it has been stuck on: "Compressing Objects: 99% (76496/76777)"

If I Ctrl-C the process, what are the consequences? Will my repo be unusable? My intuition says no, but I'd like some opinions. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伴梦长久 2024-11-15 17:54:51

git 应该永远不会受到这样的干扰。不过,如果您担心,我建议 Ctrl+Z 然后运行 ​​git fsck --full 以确保系统一致。

有许多 git-config 变量可以帮助您的 git-gc 运行得更快。我在一个特定的大型存储库上使用以下内容,但还有更多选项可以随机尝试(或仔细研究,以两者为准)。

git config pack.threads 1
git config pack.deltaCacheSize 1
git config core.packedGitWindowSize 16m
git config core.packedGitLimit 128m
git config pack.windowMemory 512m

仅当您的问题是内存不足时,这些才有帮助。

请注意,Brian J Murray 报告了最佳 (git-gc) 性能,pack.threads 应设置为您拥有的核心数量。另请注意 VonC 的另一个答案,它说您可以通过将 gc.aggressiveDepth 设置为小于默认值 250 的值来权衡 gc 性能和磁盘使用情况。

git is supposed to be always safe from interruptions like this. If you are worried, though, I suggest Ctrl+Z and then run a git fsck --full to make sure the system is consistent.

There are a number of git-config variables which might help your git-gc go faster. I use the following on one particular large repo, but there are many more options to randomly try (or carefully study, whichever).

git config pack.threads 1
git config pack.deltaCacheSize 1
git config core.packedGitWindowSize 16m
git config core.packedGitLimit 128m
git config pack.windowMemory 512m

These only help if your problem is that you are running out of memory.

Note that Brian J Murray reports for best (git-gc) performance, pack.threads should be set to the number of cores you have. Also note the other answer by VonC which says you can trade gc performance against disk usage by setting gc.aggressiveDepth to a smaller value than the default of 250.

爱情眠于流年 2024-11-15 17:54:51

FWIW,我刚刚通过使用 CTRL+C 中止 git gc 来损坏存储库。 git fsck 现在显示以下错误:

error: HEAD: invalid sha1 pointer [...]
error: refs/heads/master does not point to a valid object!
notice: No default references

并且有很多错误

dangling commit [...]

我不会对此进行调查,但我想指出我将避免中止 git gc< /代码>。

FWIW, I just corrupted a repository by aborting git gc with CTRL+C. git fsck now shows the following errors:

error: HEAD: invalid sha1 pointer [...]
error: refs/heads/master does not point to a valid object!
notice: No default references

And quite a few

dangling commit [...]

I'm not going to investigate on this, but I would like to point out that I'm going to avoid aborting git gc.

放赐 2024-11-15 17:54:51

注意:有一个有趣的演变git 2.0(2014 年第 2 季度)

“git gc --aggressive”学习了“--深度”选项和“gc.aggressiveDepth”配置变量,以允许使用比内置默认值 250 更不疯狂的深度。

这在 提交 125f814,由 Nguyễn Thái Ngọc Duy (pclouds)

1c192f3gc --aggressive)时:让它变得非常激进 - 2007-12-06)将 --depth=250 设置为默认值,它并没有真正解释背后的原因,特别是 --depth 的优缺点=250

下面一封来自 Linus 的旧邮件详细解释了这一点。
长话短说,--depth=250 是一个磁盘节省者和性能杀手
并非所有人都同意这种侵略性。
让用户配置它。

这可以帮助避免在大型存储库上运行该命令时遇到的“冻结”问题。

Note: there is an interesting evolution for git 2.0 (Q2 2014):

"git gc --aggressive" learned "--depth" option and "gc.aggressiveDepth" configuration variable to allow use of a less insane depth than the built-in default value of 250.

This is described in commit 125f814, done by Nguyễn Thái Ngọc Duy (pclouds):

When 1c192f3 (gc --aggressive: make it really aggressive - 2007-12-06) made --depth=250 the default value, it didn't really explain the reason behind, especially the pros and cons of --depth=250.

An old mail from Linus below explains it at length.
Long story short, --depth=250 is a disk saver and a performance killer.
Not everybody agrees on that aggressiveness.
Let the user configure it.

That could help avoiding the "freeze" issue you have when running that command on large repos.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文