Skip to content

Instantly share code, notes, and snippets.

@punyaruchal
Last active December 6, 2024 07:13
Show Gist options
  • Save punyaruchal/958cec2789a3d43916b5d35a86418f24 to your computer and use it in GitHub Desktop.
Save punyaruchal/958cec2789a3d43916b5d35a86418f24 to your computer and use it in GitHub Desktop.
Solution of git status/commands slow in WSL2

I came up with a dumb but useful workaround for this specific case. It works because windows git is faster against ntfs and I don't need any linux specific things for git at least.

I put this in my bash .profile

# checks to see if we are in a windows or linux dir
function isWinDir {
  case $PWD/ in
    /mnt/*) return $(true);;
    *) return $(false);;
  esac
}
# wrap the git command to either run windows git or linux
function git {
  if isWinDir
  then
    git.exe "$@"
  else
    /usr/bin/git "$@"
  fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment