导致 git gc --auto 的所有命令列表

发布于 2024-10-19 15:20:25 字数 669 浏览 2 评论 0原文

是否有导致 git gc --auto 运行的明确命令列表? git-gc(1) 手册页简单地指出:

--自动

使用此选项,git gc 检查是否需要任何内务处理;如果不是,则退出而不执行任何工作。 某些 git 命令在执行可能创建许多松散对象的操作后运行 git gc --auto

(强调)

我正在组织从 SVN 到 Git 的大型迁移。绝大多数用户将使用 Windows PC,其中相当一部分是非技术用户。他们将使用 TortoiseGit(因为它与他们已经熟悉的 TortoiseSVN 非常匹配) - 我注意到 TortoiseGit 根本不包含任何手动运行 git gc 的功能。

不能指望非技术人员必须启动“git bash”命令行才能从适当的工作目录运行 git gc --auto ;由于我们使用的是 MsysGit 的“便携式”发行版,因此它们不会有“Git GUI Here..”Windows shell 上下文菜单快捷方式。

预计随着时间的推移,Git 将主要进行自我维护是否合理,或者我是否需要尝试找出一种非技术用户友好的方法来调用 git gc --auto ?

Is there a definitive list of commands anywhere that cause git gc --auto to run? The git-gc(1) man page simply states:

--auto

With this option, git gc checks whether any housekeeping is required; if not, it exits without performing any work. Some git commands run git gc --auto after performing operations that could create many loose objects.

(emphasis added)

I'm in the process of organising a large migration from SVN to Git. The overwhelming majority of users will be on Windows PCs, and a not-insignificant portion of them are non-technical. They will be using TortoiseGit (as it closely matches TortoiseSVN, which they are already familiar with) - I've noticed that TortoiseGit does not include any functionality to run git gc manually at all.

The non-technical staff cannot be expected to have to launch a "git bash" command line to run git gc --auto from the appropriate working dir; and as we are using the "portable" distribution of MsysGit they will not have the "Git GUI Here.." windows shell context menu shortcut.

Is it reasonable to expect that over time Git will mostly self-maintain, or do I need to try and work out a non-technical user friendly method of invoking git gc --auto?

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

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

发布评论

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

评论(2

谢绝鈎搭 2024-10-26 15:20:25
builtin/merge.c:            const char *argv_gc_auto[] = { "gc", "--auto", NULL };
builtin/receive-pack.c:     "gc", "--auto", "--quiet", NULL,
git-am.sh:                  git gc --auto
git-rebase--interactive.sh: git gc --auto &&
git-svn.perl:               command_noisy('gc', '--auto');

从 git.git 上的 git grep -- --auto 来看,这些结果看起来很有趣。值得注意的是 builtin/merge.c ,这意味着如此常见的 git pull 应该触发 git gc --auto

此外,除非你的“非技术”员工正在做相当“高级”的事情(此时他们将不再是“非技术”),我不明白为什么他们需要运行 git手动 gc 而不是仅仅让 git gc --auto 处理所有事情。

builtin/merge.c:            const char *argv_gc_auto[] = { "gc", "--auto", NULL };
builtin/receive-pack.c:     "gc", "--auto", "--quiet", NULL,
git-am.sh:                  git gc --auto
git-rebase--interactive.sh: git gc --auto &&
git-svn.perl:               command_noisy('gc', '--auto');

From git grep -- --auto on git.git, those results looked interesting. The notable one is builtin/merge.c meaning that the ever so common git pull should trigger a git gc --auto.

Additionally, unless your 'non-technical' staff is doing rather 'advanced' stuff (at which point they wouldn't be 'non-technical' anymore), I don't see why they would ever need to run git gc manually instead of just letting git gc --auto handle everything.

我很OK 2024-10-26 15:20:25

使用 Git 2.17(2018 年第 2 季度),您必须将 git commit 添加到触发 git gc --auto 的命令列表中。
事实上,从 Git 诞生之初就应该如此。

请参阅 提交 095c741(2018 年 2 月 28 日),作者:Ævar Arnfjörð Bjarmason (avar)
(由 Junio C Hamano -- gitster -- 合并于 提交 9bb8eb0,2018 年 3 月 8 日)

commit:在 post-commit 钩子之前运行 git gc --auto

git-commit 的行为更改回原来的状态
d4bb43e ("调用 "git gc --auto"来自 commitmergeam
rebase。”,2007-09-05,Git v1.5.4-rc0),当它是git-commit.sh时。

不久之后在 f5bbc32 (“端口 git commit 到 C。”,2007-11-08,Git v1.5.4-rc0)当它移植到 C 时,“git gc --auto”调用消失了。

由于意外回归,git gc --auto 仅运行 git-am
git-mergegit-fetchgit-receive-pack
可以编写一个在本地“git commit”大量数据的脚本,而 gc 永远不会运行。

一个这样的存储库,它在本地提交生成的区域文件
在添加每日 cronjob 之前,更改的大小已增长到约 60GB
到“git gc”,将其减少到 1GB 以下。这将使这样的
案例无需干预即可运行。

我认为修复存储库将会增长的病态情况
永远是花费一些时间的值得的权衡
调用“git gc --auto”的毫秒数(在常见情况下
不执行任何操作)。


您可以在 Git 2.27(2020 年第 2 季度)中找到此列表的另一个示例,其中教授“am”、“commit”、“merge”和“rebase”,当它们与“--quiet”选项一起运行时,将“--quiet”传递给“<代码> gc --auto ”。

请参阅 提交 7c3e9e8提交 850b6ed(2020 年 5 月 6 日),作者: Junio C滨野 (gitster)
(由 Junio C Hamano -- gitster -- 合并于 提交 3af459e,2020 年 5 月 13 日)

auto-gc:提取可重用的助手来自“git fetch

审阅者:Taylor Blau

返回1991006cfetch:转换< code>argv_gc_auto 到 struct argv_array,2014-08-16,Git v2.1.1),我们教“git fetch --quiet”传递“ --quiet”选项降至“gc --auto”。

但是,这个问题并不限于“fetch”:

$ git grep -e 'gc.*--auto' \*.c

查找“am”、“commit”、“merge”和“rebase”中的命中当这些命令本身被告知保持安静时,它们不会将“--quiet”传递给“gc --auto”。

作为准备步骤,我们引入一个辅助函数 run_auto_gc(),调用者可以传递一个布尔值“quiet”,然后重做对“>git fetch”使用助手。

With Git 2.17 (Q2 2018), you will have to add git commit to the list of commands triggering a git gc --auto.
Actually, that should have been the case since the beginning of Git.

See commit 095c741 (28 Feb 2018) by Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano -- gitster -- in commit 9bb8eb0, 08 Mar 2018)

commit: run git gc --auto just before the post-commit hook

Change the behavior of git-commit back to what it was back in
d4bb43e ("Invoke "git gc --auto" from commit, merge, am and
rebase.", 2007-09-05, Git v1.5.4-rc0) when it was git-commit.sh.

Shortly afterwards in f5bbc32 ("Port git commit to C.", 2007-11-08, Git v1.5.4-rc0) when it was ported to C, the "git gc --auto" invocation went away.

Since that unintended regression, git gc --auto only ran for git-am,
git-merge, git-fetch, and git-receive-pack.
It was possible to write a script that would "git commit" a lot of data locally, and gc would never run.

One such repository that was locally committing generated zone file
changes had grown to a size of ~60GB before a daily cronjob was added
to "git gc", bringing it down to less than 1GB. This will make such
cases work without intervention.

I think fixing such pathological cases where the repository will grow
forever is a worthwhile trade-off for spending a couple of
milliseconds calling "git gc --auto" (in the common cases where it
doesn't do anything).


You can find another illustration of this list with Git 2.27 (Q2 2020), which teach "am", "commit", "merge" and "rebase", when they are run with the "--quiet" option, to pass "--quiet" down to "gc --auto".

See commit 7c3e9e8, commit 850b6ed (06 May 2020) by Junio C Hamano (gitster).
(Merged by Junio C Hamano -- gitster -- in commit 3af459e, 13 May 2020)

auto-gc: extract a reusable helper from "git fetch"

Reviewed-by: Taylor Blau

Back in 1991006c (fetch: convert argv_gc_auto to struct argv_array, 2014-08-16, Git v2.1.1), we taught "git fetch --quiet" to pass the "--quiet" option down to "gc --auto".

This issue, however, is not limited to "fetch":

$ git grep -e 'gc.*--auto' \*.c

finds hits in "am", "commit", "merge", and "rebase" and these commands do not pass "--quiet" down to "gc --auto" when they themselves are told to be quiet.

As a preparatory step, let's introduce a helper function run_auto_gc(), that the caller can pass a boolean "quiet", and redo the fix to "git fetch" using the helper.

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