Why is git bash for windows slow except when offline?

561 views Asked by At

When opening Git bash or running any command, the time it takes to complete these actions is agonizingly long. The startup time is also way too long. However, if I disable my network connection, it works normally. Here is what I have tried that didn't work:

  • Commenting out "helper = manager" in the config.
  • Changing the credential provider from Azure, which it was set to a long time ago, back to https://www.github.com/ in the config.
  • Running Bash as an administrator.
  • Making sure $HOME points to a local directory.

I saw something about an AMD issue and switching to integrated graphics, but I don't have an AMD graphics card and I play games that would be unplayable on integrated graphics. Given that I have to work with a remote repo for school, disabling my network connection is not an option either. I also don't want to switch to the windows command shell, and I don't have another device.

I'm not sure how to check trace logs, but I'm willing to try. I'm running on Windows 10 with bash version 5.2.15(1)-release, and my profile . Any ideas on what I'm missing?

1

There are 1 answers

9
VonC On

First, check what $HOME is when opening a bash: any $HOME on a network drive is bound to slow Git operation.

Second, activate trace2 API (Git 2.22+, Q2 2019), especially the perf one:

$ export GIT_TRACE2_PERF_BRIEF=1
$ export GIT_TRACE2_PERF=~/log.perf
git version

You can then see what takes time in a typical Git operation.

As noted in the discussion, the same commands executed from a CMD with the right %PATH% are working just fine, even with network connected.

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set "GH=%ProgramFiles%\Git"
set "PATH=%GH%\bin;%GH%\cmd;%GH%\usr\bin;%GH%\mingw64\bin;%GH%\mingw64\libexec\git-core;%PATH%"

As noted by Raymond Chen in the comments, double-check your .bashrc and see if a $PS1 (__git_ps1) is the culprit: the prompt could take time to be formed after each command execution.
Shortening said prompt should help.