SHEET 03blog/wsl-git-over-mnt-is-slow/ REVISED 

My Claude Code status line took 26 seconds: WSL git over /mnt

A status line that ran WSL git on a Windows drive took 11 to 26 seconds per run. One git.exe call for /mnt paths brought it down to about 1.1 seconds.

Published
Length
3 min read

My Claude Code status line was taking 11 to 26 seconds per run in one repo, and 7 minutes 29 seconds on a cold run. The cause was WSL’s git status reading a repo on the Windows D: drive through /mnt/d. For /mnt paths the script now makes one call to Windows’ git.exe, and a run takes about 1.1 seconds.

How it showed up

Claude Code panes felt laggy, but only in one place: sessions launched from Windows in a repo on D:. Claude panes running inside WSL were fine, and so were plain shells in the same folder. That pattern pointed at something Claude Code ran per session rather than at the machine.

How I found it

On Windows, the status line setting was wsl.exe bash ~/.claude/statusline-command.sh. I share one script between the Windows and the WSL instances of Claude Code, so the Windows one goes through wsl.exe to run it. The script converts the session’s working directory from D:\... to /mnt/d/... and runs git status --porcelain there to decide whether to draw the dirty dot next to the branch name.

So I timed each piece against the same repo, which has 2,606 tracked files:

What Time
WSL git status on /mnt/d 11 to 26 s per run, 7 min 29 s cold
Windows git, run natively about 190 ms
git.exe called from inside WSL about 2 s
Launching wsl.exe with nothing to do 320 to 570 ms

The status line runs over and over during a session, and every run was paying for a full git status across the share.

Why it’s slow

WSL2 reaches Windows drives over the 9P file-sharing protocol. git status checks every tracked file, and each of those checks crosses that boundary. Windows git reads the same files straight from NTFS, which is why it finishes in a fraction of a second.

My first idea was to skip only the dirty check. That wasn’t enough: under disk load, WSL’s rev-parse and branch lookups on /mnt/d alone took 2.5 to 4.5 seconds. The slowness was in every WSL git call on that path.

The fix

For any working directory under /mnt/, the script hands the job to git.exe and asks for the branch and the dirty state in one call. status --porcelain -b prints a ## branch...upstream header line, followed by one line per changed file:

case "$wsl_cwd" in
  /mnt/*)
    # WSL git over /mnt (9P) takes seconds per call; one git.exe call gives branch + dirty
    st=$(git.exe -C "$(wslpath -w "$wsl_cwd")" status --porcelain -b 2>/dev/null)
    if [ -n "$st" ]; then
      branch=${st%%$'\n'*}; branch=${branch%$'\r'}; branch=${branch#'## '}; branch=${branch%%...*}
      [ "${st#*$'\n'}" != "$st" ] && dirty="●"
    fi
    ;;
  *)
    # native Linux paths keep using WSL git
    ;;
esac

The branch is the first line with the ## prefix and the ...upstream suffix removed. The \r gets stripped because Windows git ends its lines with CRLF. If there’s a second line, something changed, so the repo is dirty.

Repos on the Linux filesystem still use WSL git, which is fast there. A run in the D: repo now takes about 1.1 seconds, including the wsl.exe launch.

What to check in your own setup

  • If Claude Code launched from Windows feels slow in a repo on C: or D:, time your status line before anything else. It runs constantly and you never see how long it takes.
  • Any script that runs WSL git on /mnt/* will be slow on a repo of real size. Use git.exe for those paths, or keep the repo on the Linux side.
  • Put branch and dirty state in one git status --porcelain -b call. Each extra process costs seconds when it has to cross between the two systems.
  • To test the script from Git Bash, set MSYS_NO_PATHCONV=1 and run it from a script file. Passing it inline through wsl.exe bash -c mangles the quoting.
About the author

Software engineer and serial founder in Alexandria, Egypt, and CTO at Zaher.AI, a GEO and SEO agency serving MENA.

Console

Type help and press Enter.