Home Improve the performance of git on WSL2
Post
Cancel

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:

1
2
3
4
5
6
7
function git() {
  if [[ $(pwd -P) = /mnt/* ]]; then
    git.exe "$@"
  else
    command git "$@"
  fi
}

And that’s all 🙈🙉🙊

This post is licensed under CC BY 4.0 by the author.