DEV Community

loading...
Cover image for Improve the performance of git on WSL2

Improve the performance of git on WSL2

ptrstpp950 profile image Piotr Stapp Originally published at stapp.space ・1 min read

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

Discussion (0)

Forem Open with the Forem app