简体   繁体   中英

Slow git autocomplete with WSL2 and zsh

I recently switched from git bash on windows to using WSL2 almost exclusively.

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).

What can I do to isolate the problem or resolve ( less than 1 second to autocomplete) it?

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.

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.

In order to speed up the branch-name autocomplete, you could move the repo to the linux partition. If that's not an option, you could write your own autocomplete script that avoids IO with the windows filesystem.

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

Disable oh-my-zsh git prompt magic.

Root cause is WSL using the slow 9P protocol to access Windows drive.
ref. https://stackoverflow.com/a/68974497/135962

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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