简体   繁体   English

使用 WSL2 和 zsh 自动完成速度慢 git

[英]Slow git autocomplete with WSL2 and zsh

I recently switched from git bash on windows to using WSL2 almost exclusively.我最近从 git bash 切换到 windows 几乎完全使用 WSL2。

The issue I am having is that my tab autocompletes for branches is insanely slow (in the seconds).我遇到的问题是我的标签自动完成分支非常慢(在几秒钟内)。 Other autocomplete are fast, such as autocompleting git commands (git checko[TAB] would autocomplete to checkout without problem).其他自动完成速度很快,例如自动完成 git 命令(git checko[TAB] 会自动完成结帐而不会出现问题)。

What can I do to isolate the problem or resolve ( less than 1 second to autocomplete) it?我能做些什么来隔离问题或解决它(自动完成不到 1 秒)?

In order to autocomplete branches, bash has to parse files from the .git/refs directory or .git/packed-refs file, where the branch/tag names are stored.为了自动完成分支,bash 必须解析.git/refs目录或.git/packed-refs文件中的文件,其中存储了分支/标签名称。

If your repo is stored on the windows partition, this might be the reason why it's slow, as the windows/linux filesystem interop is known to be slow as of now.如果您的存储库存储在 windows 分区上,这可能是它运行缓慢的原因,因为目前已知 windows/linux 文件系统互操作性很慢。

In order to speed up the branch-name autocomplete, you could move the repo to the linux partition.为了加快分支名称自动完成,您可以将 repo 移动到 linux 分区。 If that's not an option, you could write your own autocomplete script that avoids IO with the windows filesystem.如果这不是一个选项,您可以编写自己的自动完成脚本,以避免 IO 与 windows 文件系统。

git config --global oh-my-zsh.hide-info 1

Disable oh-my-zsh git prompt magic.禁用 oh-my-zsh git 提示魔法。

Root cause is WSL using the slow 9P protocol to access Windows drive.根本原因是 WSL 使用慢速 9P 协议访问 Windows 驱动器。
ref.参考。 https://stackoverflow.com/a/68974497/135962 https://stackoverflow.com/a/68974497/135962

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM