windows - 为什么 'git log' 在 Windows 7 64 上这么慢?

标签 windows git

我在 windows7 命令行上使用“git log”,它非常慢。

我试过:Git/Bash is extremely slow in Windows 7 x64

但这并没有帮助。我怎样才能加快速度?

最佳答案

使用最新的 Git for Windows Git 2.20.1 检查问题是否仍然存在

Git 2.21(2019 年第一季度)将提高特定形式 git log 的速度:
git log -G<regex>在“git log -p”补丁输出中寻找一个大块,其中包含与给定模式匹配的字符串。
Optimize this code to ignore binary files , 默认情况下不会显示任何匹配任何模式的 block (除非 textconv--text 选项有效)。

参见 commit e0e7cb8 (2018 年 12 月 14 日)Thomas Braun ( t-b ) .
(由 Junio C Hamano -- gitster -- merge 于 commit ecdc7cb ,2019 年 1 月 14 日)

log -G: ignore binary files

The -G<regex> option of log looks for the differences whose patch text contains added/removed lines that match regex.

Currently -G looks also into patches of binary files (which according to LibXDiff) is binary as well.

This has a couple of issues:

  • It makes the pickaxe search slow.
    In a proprietary repository of the author with only ~5500 commits and a total .git size of ~300MB:

searching takes ~13 seconds

$time git log -Gwave > /dev/null
real    0m13,241s
user    0m12,596s
sys     0m0,644s

whereas when we ignore binary files with this patch it takes ~4s:

$time ~/devel/git/git log -Gwave > /dev/null

real    0m3,713s
user    0m3,608s
sys     0m0,105s

which is a speedup of more than fourfold.

  • The internally used algorithm for generating patch text is based on xdiff and its states in LibXDiff:

The output format of the binary patch file is proprietary (and binary) and it is basically a collection of copy and insert commands [..]

这意味着一旦更改内部算法,当前格式可能会更改,因为格式不标准化。
此外 git用于为 git apply 准备补丁的二进制补丁格式与 xdiff 不同通过比较可以看出格式。

git log -p -a

commit 6e95bf4bafccf14650d02ab57f3affe669be10cf
 Author: A U Thor <author@example.com>
 Date:   Thu Apr 7 15:14:13 2005 -0700

修改二进制文件

diff --git a/data.bin b/data.bin
index f414c84..edfeb6f 100644
--- a/data.bin
+++ b/data.bin
@@ -1,2 +1,4 @@
 a
 a^@A
+a
+a^@A

git log --binary

commit 6e95bf4bafccf14650d02ab57f3affe669be10cf
Author: A U Thor <author@example.com>
Date:   Thu Apr 7 15:14:13 2005 -0700

修改二进制文件

diff --git a/data.bin b/data.bin
index f414c84bd3aa25fa07836bb1fb73db784635e24b..edfeb6f501[..]
GIT binary patch
literal 12
QcmYe~N@Pgn0zx1O01)N^ZvX%Q

literal 6
NcmYe~N@Pgn0ssWg0XP5v

这似乎出乎意料。

为解决这些问题,此补丁使 -G<regex>默认忽略二进制文件
支持 Textconv 过滤器,也支持 -a/--text恢复旧的和损坏的行为。

-S<block of text> log 的选项寻找改变文件中指定文本 block (即添加/删除)出现次数的差异。由于我们希望保持当前行为,因此添加一个测试以确保它保持这种状态。

关于windows - 为什么 'git log' 在 Windows 7 64 上这么慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37581931/

相关文章:

git - 致命: unable to access 'https://github.com/usename/my-project.git/' : The requested URL returned error: 403 Mac

linux - 根据文件扩展名过滤 git diff-tree 的输出

windows - 尝试使用 PowerShell 2.0 将 regfile 复制到另一个文件夹

Windows批处理在for循环中迭代 token

Windows 版 PHP 5.5 中缺少 php_zip.dll

Java:如何获得永不更改的计算机的唯一序列号

git - 如何从特定文件中的一系列提交中挑选更改?

git - CPack:仅打包 git 跟踪的文件

git - gitrebase 的 Vim 文件类型插件

windows - 如何正确循环/获取文本/选择 SysTreeView32 窗口项