如何跳过“松散对象” 运行“git gui”时弹出窗口

发布于 2024-07-27 17:04:04 字数 352 浏览 2 评论 0原文

当我运行“git gui”时,我会收到一个弹出窗口,显示

This repository currently has approximately 1500 loose objects.

“然后建议压缩数据库”。 我之前已经这样做过,它将松散对象减少到大约 250 个,但这并不能抑制弹出窗口。 再次压缩不会改变松散对象的数量。

我们当前的工作流程需要大量使用“rebase”,因为我们正在从 Perforce 过渡,而 Perforce 仍然是规范的 SCM。 一旦 Git 成为规范的 SCM,我们将进行定期合并,松散对象问题应该会大大缓解。

与此同时,我真的很想让这个“有用的”弹出窗口消失。

When I run 'git gui' I get a popup that says

This repository currently has approximately 1500 loose objects.

It then suggests compressing the database. I've done this before, and it reduces the loose objects to about 250, but that doesn't suppress the popup. Compressing again doesn't change the number of loose objects.

Our current workflow requires significant use of 'rebase' as we are transitioning from Perforce, and Perforce is still the canonical SCM. Once Git is the canonical SCM, we will do regular merges, and the loose objects problem should be greatly mitigated.

In the mean time, I'd really like to make this 'helpful' popup go away.

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

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

发布评论

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

评论(5

ゝ杯具 2024-08-03 17:04:04

由于还没人给出答案,我研究了代码,看看如何删除显示该对话框的代码。 我找到了执行此操作的 hint_gc 过程以及调用它的位置。 与此同时,我注意到 2011 年末添加了用于禁用对话框的配置选项 。 此更改(git-gui 0.16.0 的一部分)已于 2011-12-14 合并到 Git 的主线

因此,如果您使用 Git v1.7.9 或更高版本,则可以使用以下命令禁用警告对话框:

git config --global gui.gcwarning false

如果您使用的是旧版本,则可以编辑 /lib/git-core /git-gui 并删除 after 1000hint_gc 行,或编辑 /usr/share/git-gui/lib/database.tcl 并删除正文hint_gc 过程的一部分。 (这些文件路径位于 Cygwin 上 - 在其他环境中,文件可能位于不同的位置。对于 Windows,它是 c:\Program Files\Git\mingw64\libexec\git-core\git-gui.tcl代码>)

Since nobody had yet an answer, I looked into the code to see how to remove the code which shows up that dialog. I found the hint_gc procedure which does it and the place where it is called. At the same time I noticed that late 2011 there was added a configuration option for disabling the dialog. This change (part of git-gui 0.16.0) was merged to Git's mainline on 2011-12-14.

So if you use Git v1.7.9 or newer, you can disable the warning dialog with the following command:

git config --global gui.gcwarning false

If you are using an older version, then you can edit /lib/git-core/git-gui and remove the after 1000 hint_gc line, or edit /usr/share/git-gui/lib/database.tcl and remove the body of the hint_gc procedure. (These file paths are on Cygwin - on other environments the files might be in a different locations. For Windows it is c:\Program Files\Git\mingw64\libexec\git-core\git-gui.tcl)

吃不饱 2024-08-03 17:04:04

更新: git prune 将“解决”该问题,因为它将删除那些松散的物体
git gc 调用 git prune< /code>,但默认情况下仅适用于两周以上的松散物体)。
然而,正如 OP Michael Donohue 在评论中提到的:

我确实喜欢将松散的物体保留两周的安全性,如果我想回去看看一些旧的修订版,所以我不太喜欢这个解决方案。
我对 git 的大小或性能没有任何问题,只是“git gui”坚持要求我压缩数据库,即使压缩数据库没有效果。


原始答案:

git gc”未删除所有松散对象的问题之前已报告过(2008年底,“"git gc" 似乎不再删除松散的对象"

git gc 仅删除两周以上的松散对象,如果您现在确实想删除它们,请运行 git prune。
但请确保运行时没有其他 git 进程可以处于活动状态,否则它可能会执行以下操作:
在某事上。

git gc”将解压无法访问且当前位于包中的对象。
因此,在“git gc”操作之后,git 存储库使用的磁盘空间量实际上会增加,这对于正在运行的人来说可能会感到惊讶他们的文件系统接近完整,从跟踪存储库中删除许多分支,然后执行“git gc”可能会得到一个非常不愉快的惊喜。

[示例:] 旧分支通过 next-20081204 等标签保留。
如果您每天更新 linux-next 存储库的本地副本,您将积累大量这些旧分支标签。
如果你随后删除一整串,并运行 git-gc,该操作将需要相当长的时间,并且使用的块和 inode 的数量将显着增加。

它们会在“git prune”之后消失,但是当我执行此内务操作时,我经常希望有一个--yes-I-know-what-I- am-doing-and-it's-unsafe-but-just-drop-the-unreachable-objects-cause-this-is-just-a-tracking-repository 选项“git gc”。

那么就您而言,“git prune”会有帮助吗?

(可能在 gc.pruneexpire 配置变量中使用“now”,这是发生上述行为所必需的)。


您还拥有(来自同一线程):

repack -a -d -l

注意小写的“a”。

git-gc 使用大写“A”调用 repack,这会导致无法访问的对象被解包。 小“a”适合那些知道自己在做什么并且希望 git 删除无法访问的对象的人。

Update: git prune would "solve" the issue, in that it will remove those loose objects
(git gc calls git prune, but only for loose objects older than two weeks, by default).
However, as the OP Michael Donohue mentions in the comments:

I do like the safety aspect of keeping the loose objects around for two weeks, should I want to go back and look at some old revisions, so I don't really like this solution.
I am not having any trouble with the size or performance of git, it is just 'git gui' that insists on asking me to compress the database, even when compressing the database would have no effect.


Original answer:

The problem of "git gc" not removing all loose objects has been reported before (late 2008, ""git gc" doesn't seem to remove loose objects any more"

git gc only removes loose objects older than two weeks, if you really want to remove them now, run git prune.
But make sure no other git process can be active when you run it, or it could possibly step
on something.

"git gc" will unpack objects that have become unreachable and were currently in packs.
As a result, the amount of disk space used by a git repository can actually go up dramatically after a "git gc" operation, which could be surprising for someone who is running close to full on their filesystem, deletes a number of branches from a tracking repository, and then does a "git gc" may get a very unpleasant surprise.

[Example:] Old branches are reserved via a tag such as next-20081204.
If you update the your local copy of the linux-next repository every day, you will accumulate a large number of these old branch tags.
If you then delete a whole series of them, and run git-gc, the operation will take quite a while, and the number of blocks and inodes used will grow significantly.

They will disappear after a "git prune", but when I do this housekeeping operation, I've often wished for a --yes-I-know-what-I-am-doing-and-it's-unsafe-but-just-drop-the-unreachable-objects-cause-this-is-just-a-tracking-repository option to "git gc".

So in your case, would a "git prune" be helpful?

(possibly with using "now" in the gc.pruneexpire config variable, needed for the above behavior to happen).


You also have (from the same thread):

repack -a -d -l

Notice the lowercase 'a'.

git-gc calls repack with uppercase 'A' which is what causes the unreachable objects to be unpacked. Little 'a', is for people who know what they are doing, and want git to just drop unreachable objects.

痴情换悲伤 2024-08-03 17:04:04

当“松散对象”弹出时,我知道是时候运行 git 的垃圾收集器了:

git gc

之后弹出窗口消失。

更新:(根据 TED 的建议)

我从 git/share/git-gui/lib/database.tcl 中提取了以下例程

您可以修改它以满足您的需要。

proc hint_gc {} {
    set object_limit 8
    if {[is_Windows]} {
        set object_limit 1
    }

    set objects_current [llength [glob \
        -directory [gitdir objects 42] \
        -nocomplain \
        -tails \
        -- \
        *]]

    if {$objects_current >= $object_limit} {
        set objects_current [expr {$objects_current * 256}]
        set object_limit    [expr {$object_limit    * 256}]
        if {[ask_popup \
            [mc "This repository currently has approximately %i loose objects.

To maintain optimal performance it is strongly recommended that you compress the database when more than %i loose objects exist.

Compress the database now?" $objects_current $object_limit]] eq yes} {
            do_gc
        }
    }
}

When "Loose Object" popup I know it's time to run git's garbage collector:

git gc

After that the popup goes away.

Update: (due to T.E.D.'s suggestion)

I extracted the below routine from git/share/git-gui/lib/database.tcl

You can modify it to meet your needs.

proc hint_gc {} {
    set object_limit 8
    if {[is_Windows]} {
        set object_limit 1
    }

    set objects_current [llength [glob \
        -directory [gitdir objects 42] \
        -nocomplain \
        -tails \
        -- \
        *]]

    if {$objects_current >= $object_limit} {
        set objects_current [expr {$objects_current * 256}]
        set object_limit    [expr {$object_limit    * 256}]
        if {[ask_popup \
            [mc "This repository currently has approximately %i loose objects.

To maintain optimal performance it is strongly recommended that you compress the database when more than %i loose objects exist.

Compress the database now?" $objects_current $object_limit]] eq yes} {
            do_gc
        }
    }
}
山有枢 2024-08-03 17:04:04

嗯......我在 文档

我想你总是可以拉下它的源代码,取出对话框的代码,然后重建。

Hmmmm....I don't see a command-line argument for that in the docs.

I suppose you could always pull down its source, take out the code for the dialog, and rebuild.

心在旅行 2024-08-03 17:04:04

添加答案和解释:

如果您想继续监视松散的对象,但不希望弹出窗口完全消失(对于较大的项目,它会一直弹出),您可以修改database.tcl,它可能位于此文件夹中:

C:\Program Files\Git\mingw64\share\git-gui\lib\

在函数 prochint_gc {} 中,

proc hint_gc {} {

set ndirs 1
set limit 8
if {[is_Windows]} {
    set ndirs 8
    set limit 1
}

您可以将其更改

set ndirs 8

set ndirs 32

例如。

To add to the answers and explanations:

If you want to continue monitoring the loose objects, but not want the popup to disappear completely (it pops all the time for larger projects), you can modify database.tcl which is probably in this folder:

C:\Program Files\Git\mingw64\share\git-gui\lib\

In the function proc hint_gc {}

proc hint_gc {} {

set ndirs 1
set limit 8
if {[is_Windows]} {
    set ndirs 8
    set limit 1
}

You can change the

set ndirs 8

to

set ndirs 32

for example.

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