我在 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 filesThe
-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/