Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

We have a very large project with almost 15.000 commits total. I run Debian 9.3 on my Windows machine using WSL. My git version is 2.17.0.

When I run commands such as git status, it takes at least 20 seconds to complete. Even if no changes were made.

I have tried multiple older versions of git and even tried Ubuntu, but I still experience the same result. I've tried running a bunch of commands from various posts on here and on other sites, but none of them worked.

Funny thing: When I open up cmd.exe or Git Bash on Windows, it takes less than a second to run git status.

What could be causing this? What can I do to fix this?

like image 354
MortenMoulder Avatar asked May 08 '18 10:05

MortenMoulder


People also ask

Can you run Git commands from terminal?

To execute Git commands on your computer, you must open a terminal (also known as command prompt, command shell, and command line).

How do I run a Git command?

All you have to do is load Command Prompt (Load the Start menu, then click "Run", type cmd and hit enter), then you can use Git commands as normal.

Does Debian have Git?

Installing Git The Git package is included in the Debian's default repositories and can be installed using the apt package manager.


1 Answers

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 repositories Plus 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.
like image 69
VonC Avatar answered Sep 20 '22 15:09

VonC