如何在 Git GUI 中显示更多“最近的存储库”?
Posted
技术标签:
【中文标题】如何在 Git GUI 中显示更多“最近的存储库”?【英文标题】:How do I show more 'recent repositories' in Git GUI? 【发布时间】:2013-07-08 07:30:18 【问题描述】:我的 Git-GUI 副本在“打开最近的存储库”列表下显示了 10 个条目。我如何将其更改为例如20?目前,每当我打开第 11 个 repo 时,列表中按字母顺序排列的最后一个就会消失 - 当列表已满时我会在 repos Zed 和 Alpha 不是他们的真名!
我没有很好地阅读 TCL,但我认为相关行是 #267,在 C:/Program Files (x86)/Git/share/git-gui/lib/choose_repository.tcl 中。我尝试以管理员身份打开我最喜欢的编辑器,将该行更改为“> 20”,重新启动 Git-GUI,然后打开另一个存储库,但这并没有帮助 - 底部条目再次被排除在列表之外。当我重新打开 choose_repository.tcl 时,我的编辑仍然存在,所以它肯定被保存了。
while [llength $recent] > 10
我该怎么办?
正在使用的软件:
Windows 7 git-gui 版本 0.17.GITGUI git 版本 1.8.3.msysgit.0 TCl/TK 版本 8.5.13 git-gui 库:C:/Program Files (x86)/Git/share/git-gui/lib【问题讨论】:
【参考方案1】:你快到了。你找到了让 git-gui 记录超过 10 个以前打开的存储库的地方。但是,用于显示存储库列表的文本小部件只有 10 行高 - 因此,如果您在第 151 行更改它,您将同时记录并查看它们。
这是一个补丁,可让您设置 gui.maxrecentrepo 并将最近存储库的最大数量固定为该值(默认为 10):
diff --git a/lib/choose_repository.tcl b/lib/choose_repository.tcl
index 657f7d5..c8d8517 100644
--- a/lib/choose_repository.tcl
+++ b/lib/choose_repository.tcl
@@ -24,6 +24,10 @@ field sorted_recent ; # recent repositories (sorted)
constructor pick
global M1T M1B use_ttk NS
+ if [set maxrecent [get_config gui.maxrecentrepo]] eq
+ set maxrecent 10
+
+
make_dialog top w
wm title $top [mc "Git Gui"]
@@ -148,7 +152,7 @@ constructor pick
-background [get_bg_color $w_body.recentlabel] \
-wrap none \
-width 50 \
- -height 10
+ -height $maxrecent
$w_recentlist tag conf link \
-foreground blue \
-underline 1
@@ -264,7 +268,11 @@ proc _append_recentrepos path
git config --global --add gui.recentrepo $path
load_config 1
- while [llength $recent] > 10
+ if [set maxrecent [get_config gui.maxrecentrepo]] eq
+ set maxrecent 10
+
+
+ while [llength $recent] > $maxrecent
_unset_recentrepo [lindex $recent 0]
set recent [lrange $recent 1 end]
【讨论】:
看起来不错,工作正常。缺少的步骤是如何通过在编辑器中打开 C:\Users\user\.gitconfig 来设置 gui.maxrecentrepo =>,找到一个写着 [gui] 的行,然后添加一个写着 maxrecentrepo = number 的新行跨度> 您也可以使用 'git config --global gui.maxrecentrepo 20' 设置此配置值——但手动编辑配置文件的工作方式相同。 该命令在 Ubuntu 中对我有效,但在 Windows7 中无效(通过 cmd.exe):“'git' 未被识别为内部或外部命令、可运行程序或批处理文件。”我怀疑你错过了一步。 也许我们缺少的步骤是将 git 添加到 PATH:***.com/questions/4492979/… 我正在寻找一种方法来更改此限制。我看到这个补丁已经applied 到了 git。所以在当前的 git 构建中,更改gui.maxrecentrepo
就足够了。以上是关于如何在 Git GUI 中显示更多“最近的存储库”?的主要内容,如果未能解决你的问题,请参考以下文章
基于 Wish 的工具(git-gui、gitk)在 macOS Monterey 上显示损坏/黑色的 UI