Running git commands on Debian & Ubuntu on WSL is really slow for large projects Running git commands on Debian & Ubuntu on WSL is really slow for large projects git git

Running git commands on Debian & Ubuntu on WSL is really slow for large projects


Update June 2019: WSL 2 is coming, and with it a full system call compatibility.
That should increase Git command performance considerably!


Original answer 2018:

Git is working best when executed on a host without any intermediate layer.

For instance, if your repo is on a shared folder, Git would be considerably slower.
In case of WSL, the repo is locally accessed, but through through a filesystem translation between various Linux file system operations into NT kernel operations.

translation

That would be enough to explain degraded performance, especially on large Git repositoriesPlus make sure your $PATH does not reference folders with Windows executable that might be called instead of the Linux ones

Possible causes:

  • filesystem emulation (slow): WSL issue 2759
  • Shell Prompt: make sure to test your command in a basic shell prompt, without any complex PS1 computation
  • Windows Defender AV: try and exclude (for testing) the WSL-managed filesystem from AV scan.


You can have some profiling details by using the GIT_TRACE_PERFORMANCE env var :

$ GIT_TRACE_PERFORMANCE=1 git status -sb -uno08:51:54.525808 read-cache.c:1889       performance: 0.000330659 s: read cache .git/index08:51:54.528532 preload-index.c:112     performance: 0.002669928 s: preload index08:51:54.528667 read-cache.c:1447       performance: 0.000109768 s: refresh index08:51:54.528892 diff-lib.c:250          performance: 0.000056516 s: diff-files08:51:54.534630 diff-lib.c:527          performance: 0.005070461 s: diff-index## wip/foo08:51:54.536419 trace.c:420             performance: 0.013503141 s: git command: git status -sb -uno


I ended up adding a hack.

    alias git=git.exe

Now, it runs windows git executable in WSL with WSL config/SSH settings.