如何跳过“松散对象” 运行“git gui”时弹出窗口
当我运行“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
由于还没人给出答案,我研究了代码,看看如何删除显示该对话框的代码。 我找到了执行此操作的
hint_gc
过程以及调用它的位置。 与此同时,我注意到 2011 年末添加了用于禁用对话框的配置选项 。 此更改(git-gui 0.16.0 的一部分)已于 2011-12-14 合并到 Git 的主线。因此,如果您使用 Git v1.7.9 或更高版本,则可以使用以下命令禁用警告对话框:
如果您使用的是旧版本,则可以编辑
/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:
If you are using an older version, then you can edit
/lib/git-core/git-gui
and remove theafter 1000 hint_gc
line, or edit/usr/share/git-gui/lib/database.tcl
and remove the body of thehint_gc
procedure. (These file paths are on Cygwin - on other environments the files might be in a different locations. For Windows it isc:\Program Files\Git\mingw64\libexec\git-core\git-gui.tcl
)更新:
git prune
将“解决”该问题,因为它将删除那些松散的物体(
git gc
调用git prune< /code>,但默认情况下仅适用于两周以上的松散物体)。
然而,正如 OP Michael Donohue 在评论中提到的:
原始答案:
“
git gc
”未删除所有松散对象的问题之前已报告过(2008年底,“"git gc
" 似乎不再删除松散的对象"那么就您而言,“
git prune
”会有帮助吗?(可能在 gc.pruneexpire 配置变量中使用“now”,这是发生上述行为所必需的)。
您还拥有(来自同一线程):
Update:
git prune
would "solve" the issue, in that it will remove those loose objects(
git gc
callsgit prune
, but only for loose objects older than two weeks, by default).However, as the OP Michael Donohue mentions in the comments:
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"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):
当“松散对象”弹出时,我知道是时候运行 git 的垃圾收集器了:
之后弹出窗口消失。
更新:(根据 TED 的建议)
我从 git/share/git-gui/lib/database.tcl 中提取了以下例程
您可以修改它以满足您的需要。
When "Loose Object" popup I know it's time to run git's garbage collector:
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.
嗯......我在 文档。
我想你总是可以拉下它的源代码,取出对话框的代码,然后重建。
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.
添加答案和解释:
如果您想继续监视松散的对象,但不希望弹出窗口完全消失(对于较大的项目,它会一直弹出),您可以修改database.tcl,它可能位于此文件夹中:
C:\Program Files\Git\mingw64\share\git-gui\lib\
在函数 prochint_gc {} 中,
您可以将其更改
为
例如。
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 {}
You can change the
to
for example.