2

I have noticed that git operations slowed down recently, it might be related to the upgrade of git and using credential-manager-core instead of credential-manager, I've tried to diagnose the issue using GCM_TRACE=1 git fetch, looks like I might have messed up my configuration:

[GetProviderAsync] Checking against 3 host providers registered with priority 'Normal'.

My colleague does not see such line and only one host provider is checked. How can I change the configuration of host providers used by git credential manager?

Update: Using a portable version of git did not help, trace output below:

[RunInternalAsync] Version: 2.0.394.50751
[RunInternalAsync] Runtime: .NET Framework 4.0.30319.42000
[RunInternalAsync] Platform: Windows (x86-64)
[RunInternalAsync] AppPath: git-credential-manager-core
[RunInternalAsync] Arguments: get
[ExecuteAsync] Start 'get' command...
[ExecuteAsync] Detecting host provider for input:
[ExecuteAsync]   protocol=https
[ExecuteAsync]   host=dev.azure.com
[ExecuteAsync]   path=........
[ExecuteAsync]   username=........
[GetProviderAsync] Performing auto-detection of host provider.
[GetProviderAsync] Checking against 3 host providers registered with priority 'Normal'.
[ExecuteAsync] Host provider 'Azure Repos' was selected.
[GetCredentialAsync] Looking for existing credential in store with service=https://........ account=...
[GetCredentialAsync] Existing credential found.
[ExecuteAsync] End 'get' command...
[RunInternalAsync] Version: 2.0.394.50751
[RunInternalAsync] Runtime: .NET Framework 4.0.30319.42000
[RunInternalAsync] Platform: Windows (x86-64)
[RunInternalAsync] AppPath: git-credential-manager-core
[RunInternalAsync] Arguments: store
[ExecuteAsync] Start 'store' command...
[ExecuteAsync] Detecting host provider for input:
[ExecuteAsync]   protocol=https
[ExecuteAsync]   host=........
[ExecuteAsync]   path=................
[ExecuteAsync]   username=..............
[ExecuteAsync]   password=********
[GetProviderAsync] Performing auto-detection of host provider.
[GetProviderAsync] Checking against 3 host providers registered with priority 'Normal'.
[ExecuteAsync] Host provider 'Azure Repos' was selected.
[StoreCredentialAsync] Storing credential with service=............. account=...............
[StoreCredentialAsync] Credential was successfully stored.
[ExecuteAsync] End 'store' command...

Number of registered host providers seems suspicious but I do not know how it can be changed. Also - storing credentials on each fetch does not seem like an efficient thing to do.

Update 2: Switching to SSH authorization did not help much, so the root cause of delays is not related to GCM. I'll investiage a bit more and probably close the question.

Wojtek
  • 1,390
  • 1
  • 19
  • 38
  • Did you use a portable Git with a `%PATH%` which *only* referenced that Git, and no other programs? (to minimize any side effect from other programs) – VonC Mar 31 '21 at 22:13
  • Yes, the only thing that was common with my previous setup is a change to gitconfig: `[credential] useHttpPath = true helper = manager-core` – Wojtek Mar 31 '21 at 22:15
  • Does the issue persists when there are less entries (like no entry for `dev.azure.com` for example)? DO you reproduce the issue with the same latest Git (2.31.1) on other machines? – VonC Mar 31 '21 at 22:19
  • The thing is that I do not know how to change host providers used by git credential managers, docs are scarce for that subject. Deleting credentials stored in windows Credential Manager does not help - they are recreated after fetch, revoking PATs in Azure Devops also does not help. – Wojtek Mar 31 '21 at 22:38
  • I cannot attempt a repro on other machine with my account due to security, colleagues do not have this issue, the difference is that they have only one host provider mentioned in trace. – Wojtek Mar 31 '21 at 22:45
  • 1
    The latest GCM release does remove those messages. See [my updated answer](https://stackoverflow.com/a/66838111/6309) below. – VonC Nov 16 '21 at 16:36

2 Answers2

2

I did not use the git trace as you did when I had a similar issue, but I was getting 3 "detecting host provider for" messages every time I did a fetch. I was on git 2.33.1.windows.1 and wasn't using https remotes before then. (2.33.1 stopped allowing rsa/sha-1 keys apparently, and I switched to personal access tokens while troubleshooting.) I was already using credential manager core so my solution was to add a credential.provider setting to .gitconfig telling it that I am connecting to a bitbucket server.

[credential]
    helper = manager-core
[credential "https://example.com"]
    provider = bitbucket

After doing this I don't get any "detecting host provider" messages and git fetch runs much faster now. https://github.com/microsoft/Git-Credential-Manager-Core/blob/main/docs/configuration.md

BlueBayliss
  • 81
  • 1
  • 6
  • Do you have any idea what should be the configuration for gitlab? I was having two lines of `detecting host provider` with gitlab. I added `provider = generic` for it, and it increased to three. `auto` works like no config - two messages. – tpwo Oct 26 '21 at 15:51
  • 1
    I would try all of the possibilities to see if any of the others gave a better result since "auto" is finding a way that works. I did find an open issue to add gitlab as a credential provider. Or you can ignore all of that and use SSH. https://gitlab.com/gitlab-org/gitlab/-/issues/225215 – BlueBayliss Oct 28 '21 at 14:39
  • 1
    At work, I had issues to set it up with corporate GitHub and Bitbucket as well (I guess that we're using some older version). But you're right, I'll go with SSH. Thanks! – tpwo Oct 28 '21 at 19:24
1

Test if this is linked to your current Git for Windows installation by:

set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%GH%\mingw64\libexec\git-core;%PATH%
  • checking if the issue persists on git fetch

That way, you don't disturb your current setup, and limit your tests to a single CMD session.


Update Nov. 2021: Git-Credential-Manager-Core v2.0.603 does remove those messages.
It is not yet packaged with the latest Git for Windows, like the recent 2.34.0, but expect it in 2.34.1.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250