DEV Community

Cover image for Improve the performance of git on WSL2
Piotr Stapp
Piotr Stapp

Posted on • Originally published at stapp.space

Improve the performance of git on WSL2

I've returned to Windows after a year on the Mac. I built up pwsh and added a lot of tools, but I still need some Linux/MacOS ones, such as envsubst. Of course, WSL2 comes to the rescue, but you'll have to checkout the repo twice for Linux and Visual Studio. It is ridiculous.
I set up oh-my-posh with powerline on WSL2, which is a fantastic combination. However, there is a "but": git status is quite slow. What is the reason for this? Just read 4197

How can this be resolved? Simply replace the git command with the git function, as shown below:

function git() {
  if [[ $(pwd -P) = /mnt/* ]]; then
    git.exe "$@"
  else
    command git "$@"
  fi
}
Enter fullscreen mode Exit fullscreen mode

And that's all 🙈🙉🙊

Top comments (1)

Collapse
 
nelsonym profile image
nelsonym

For simplicity, here's my share github.com/microsoft/WSL/issues/44...