[英]"git branch" command is slow from Git Bash on Windows
I only have one branch main
but when I execute the git branch
command, it took about 30 seconds to complete.我只有一个分支
main
但是当我执行git branch
命令时,大约需要 30 秒才能完成。 Other commands like git status
does not have this performance issue.其他命令如
git status
没有这个性能问题。 What are some of the things that I can check here?我可以在这里检查哪些内容?
Git version is 2.36.0 running on Windows 10. Git 版本是在 Windows 10 上运行的 2.36.0。
UPDATE:更新:
git branch
completed quickly.git branch
很快完成。 BUT that is not every single time.On Windows, when the PC is in a domain, make sure that the domain controller is reachable.在 Windows 上,当 PC 在域中时,请确保域控制器可访问。
The shell and command line tools that are distributed with Git for Windows are derived from the MSYS2 project , which is based on a variant of the Cygwin library.与 Git for Windows 一起分发的 shell 和命令行工具源自MSYS2 项目,该项目基于 Cygwin 库的变体。 As part of the program startup routine, the library does several name lookups.
作为程序启动例程的一部分,该库会进行多次名称查找。 When the system is registered in a domain, this lookup goes to the domain controller.
当系统在域中注册时,此查找将转到域控制器。 In the case when the domain controller is not reachable, the lookup waits for time-outs.
在无法访问域控制器的情况下,查找会等待超时。 This causes the delays.
这会导致延迟。
The results of the lookup is cached by Windows.查找的结果由 Windows 缓存。 Therefore for a short time, subsequent startups do not have to wait for the time-outs.
因此,在短时间内,后续启动不必等待超时。 But ultimately the cache expires and the next program invocation has to wait again.
但最终缓存到期,下一次程序调用必须再次等待。
The Git program, git.exe
, is not based on the Cygwin library and does not need the name lookup. Git 程序
git.exe
不是基于 Cygwin 库,也不需要名称查找。 It can run without delay.它可以毫无延迟地运行。 However, many Git commands spawn a pager, typically
less
, which does suffer from the delay;然而,许多 Git 命令会产生一个寻呼机,通常是
less
,它确实会受到延迟的影响; therefore, it appears as if Git itself would be delayed.因此,看起来 Git 本身会被延迟。 (Not that it matters; the user experience is bad either way.)
(没关系;无论哪种方式,用户体验都很糟糕。)
On top of that there are many other cases where Git runs a command line tool: hooks, textconv filters, ssh, etc. All of them can suffer from the delay.除此之外,还有许多其他 Git 运行命令行工具的情况:钩子、textconv 过滤器、ssh 等。所有这些都可能受到延迟的影响。
EDIT: I am currently testing the following change.编辑:我目前正在测试以下更改。 Do NOT make this change to your system unless you know exactly what the security implications are.
除非您确切知道安全隐患是什么,否则不要对您的系统进行此更改。
I used mkpasswd
and mkgroup
to cache the current domain information locally:我使用
mkpasswd
和mkgroup
在本地缓存当前域信息:
mkpasswd >> /etc/passwd
mkgroup >> /etc/group
Then I removed duplicates from the files.然后我从文件中删除了重复项。 (But
/etc/group
did not exist before these commands.) (但
/etc/group
在这些命令之前不存在。)
This idea was taken from the Cygwin FAQ .这个想法取自Cygwin FAQ 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.