Improve the performance of git on WSL2

ptrstpp950

Piotr Stapp

Posted on May 19, 2021

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 🙈🙉🙊

💖 💪 🙅 🚩
ptrstpp950
Piotr Stapp

Posted on May 19, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related