16

When using git on windows normally (such as git push and git pull), it will sometimes be very slow. Running git pull over and over again returns within two seconds most of the time, but about 1/6 of attempts take about a minute.

I have set git config --global core.preloadindex and git config --global core.fscache to true.

Examples after running set GIT_TRACE=1

Slow:

$ git pull
14:11:03.166594 git.c:371               trace: built-in: git 'pull'
14:11:03.168594 run-command.c:350       trace: run_command: 'fetch' '--update-head-ok'
14:11:03.186596 git.c:371               trace: built-in: git 'fetch' '--update-head-ok'
14:11:03.189596 run-command.c:350       trace: run_command: 'git-remote-https' 'origin' 'https://[...].git'
14:11:03.204598 run-command.c:350       trace: run_command: 'git credential-manager get'
14:11:46.400917 git.c:607               trace: exec: 'git-credential-manager' 'get'
14:11:46.400917 run-command.c:350       trace: run_command: 'git-credential-manager' 'get'
14:11:47.828059 run-command.c:350       trace: run_command: 'git credential-manager store'
14:11:47.869064 git.c:607               trace: exec: 'git-credential-manager' 'store'
14:11:47.869064 run-command.c:350       trace: run_command: 'git-credential-manager' 'store'
14:11:47.980075 run-command.c:350       trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
14:11:47.991076 run-command.c:350       trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
14:11:47.999077 git.c:371               trace: built-in: git 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
14:11:48.005077 run-command.c:1130      run_processes_parallel: preparing to run up to 1 tasks
14:11:48.005077 run-command.c:1162      run_processes_parallel: done
14:11:48.005077 run-command.c:350       trace: run_command: 'gc' '--auto'
14:11:48.014078 git.c:371               trace: built-in: git 'gc' '--auto'
14:11:48.017078 run-command.c:350       trace: run_command: 'merge' 'FETCH_HEAD'
14:11:48.025079 git.c:371               trace: built-in: git 'merge' 'FETCH_HEAD'
Already up-to-date.

Fast:

$ git pull
14:12:25.432820 git.c:371               trace: built-in: git 'pull'
14:12:25.434820 run-command.c:350       trace: run_command: 'fetch' '--update-head-ok'
14:12:25.451821 git.c:371               trace: built-in: git 'fetch' '--update-head-ok'
14:12:25.454822 run-command.c:350       trace: run_command: 'git-remote-https' 'origin' 'https://[...].git'
14:12:25.472824 run-command.c:350       trace: run_command: 'git credential-manager get'
14:12:25.497826 git.c:607               trace: exec: 'git-credential-manager' 'get'
14:12:25.497826 run-command.c:350       trace: run_command: 'git-credential-manager' 'get'
14:12:26.904967 run-command.c:350       trace: run_command: 'git credential-manager store'
14:12:26.941970 git.c:607               trace: exec: 'git-credential-manager' 'store'
14:12:26.941970 run-command.c:350       trace: run_command: 'git-credential-manager' 'store'
14:12:27.050981 run-command.c:350       trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
14:12:27.060982 run-command.c:350       trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
14:12:27.068983 git.c:371               trace: built-in: git 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
14:12:27.074984 run-command.c:1130      run_processes_parallel: preparing to run up to 1 tasks
14:12:27.074984 run-command.c:1162      run_processes_parallel: done
14:12:27.074984 run-command.c:350       trace: run_command: 'gc' '--auto'
14:12:27.082985 git.c:371               trace: built-in: git 'gc' '--auto'
14:12:27.085985 run-command.c:350       trace: run_command: 'merge' 'FETCH_HEAD'
14:12:27.092986 git.c:371               trace: built-in: git 'merge' 'FETCH_HEAD'
Already up-to-date.

Edit:

After running git config --global credential.helper "" the lines in output containing credential-manager are replaced by:

17:18:44.139589 run-command.c:350       trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r -s line </dev/tty && echo "$line" && echo >/dev/tty'
Password for 'https://[...]':

A delay occurs sometimes right before the Password line is displayed, with the same duration and frequency (as far as I can tell, from about 20 tests) as before.

16
  • Did you try and deactivate the real-time analysis of your anti-virus?
    – VonC
    Commented Mar 14, 2017 at 14:21
  • @VonC: I'm experiencing same problem as OP, I got ESET. When anti-virus is disabled, the issue still occurs. Commented Mar 14, 2017 at 14:27
  • @Tatranskymedved Is is Windows 10, 7? Git 2.12?
    – VonC
    Commented Mar 14, 2017 at 14:29
  • Win10 x64 Pro, git version 2.10.2.windows.1 Commented Mar 14, 2017 at 14:29
  • 1
    My team and I used to have the same issue on a corporate server. When the repo was compressed (probably git gc or similar) or reorganised due to migrattion from one server to another, suddenly pushes were quick again. So maybe it helps to gc the upstream repo.
    – kriegaex
    Commented Mar 14, 2017 at 17:19

3 Answers 3

6
+25

Based on your trace, it seems that the authentication step is slow. I can see two main reason to this:

  • The server sometimes responds slowly. You won't be able to do anything on the client side.
  • Something is wrong with authentication on your side. The most probable cause I think, is that you may use a credential manager which cause the slowness. Try to disable it.
3
  • Well, disabling cred. manager will cause that I'm forced to enter password everytime. If there is any workaround or explanation why it is happening, it would be really appreacited. Commented Mar 17, 2017 at 6:53
  • 1
    It is difficult to say why your cred. manager is slow without investigating. Check if there is any update for it. With a bit of luck there will be one and it will solve your issue. Otherwise, I am afraid that the best alternative I can suggest you is to try using ssh urls instead of https urls for your git repo. The auth will be done with a ssh key and the key password will be prompted only once per computer start. It may be better than nothing even if it is not as good as a cred. manager :-/ Commented Mar 17, 2017 at 19:34
  • try ssh as auth will happen with key-pair and will be valid per session. Also try to verify if there is any network delay / packet loss.
    – iSensical
    Commented Mar 20, 2017 at 16:37
4

TL;DR - My slow git (GCM) was fixed by disabling .net assembly binding on my machine (via fuslogvw).

I discovered it was due to a slow git credentials manager (GCM) by running git and the GCM in trace mode:

$ SET GIT_TRACE=1 
$ SET GCM_TRACE=1
$ git fetch

The logs showed the GCM was slow. When looking at the GCM with sysinternals' process monitor to figure out what was happening, I saw it was writing heavily to disk.

Now, it turned out the GCM is a .net process, and I had configured .net to log all assembly binds to disk for debugging some process a couple of days ago (via fuslogvw - fusion log viewer).

Disabling the binding logging fixed my problem and speed returned to normal.

1
4

Please prefer ssh over https. I assume you already have GitBash so you can follow this tutorial. Make sure you clone the repo into a new directory so you don't lose your current https setup and any local changes.

If problem persists, though it would be very likely to be network issue, you can consider ssh debugging shown in this answer.

1
  • SSH is nice workaround, however I like to approach this as a solvable problem with some solution. Commented Mar 20, 2017 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.