git-ecosystem/git-credential-manager · error · Exception

No credential store has been selected. / Unknown credential…

Error message

No credential store has been selected. / Unknown credential store '{credStoreName}'.
Set the {GCM_CREDENTIAL_STORE} environment variable or the {credential}.{credentialStore} Git configuration setting to one of the following options: ...

What it means

CredentialStore.EnsureBackingStore selects the backing credential store from the GCM_CREDENTIAL_STORE environment variable or the credential.credentialStore Git config. When no store is selected (or the value names none of the known stores: wincredman, dpapi, plaintext, secretservice, gpg, keychain, cache), it builds a message listing the available options plus a help URL and throws.

Solutions

  1. Set `git config --global credential.credentialStore <store>` to one of the listed valid options (e.g. gpg, secret-service, keychain, cache, plaintext).
  2. Or export GCM_CREDENTIAL_STORE=<store> in your environment.
  3. Fix the typo/invalid value in the existing setting to match an exact supported store name.
  4. Consult the help URL in the message (GcmCredentialStores doc) for platform-appropriate choices.
  5. On Linux, ensure the chosen store's dependencies (e.g. libsecret, gpg) are installed before selecting it.

Example fix

// before (unrecognized/absent setting)
git config --global credential.credentialStore windowscredman   // typo, non-Windows default

// after
git config --global credential.credentialStore gpg   // valid store for Linux
Defensive patterns

Strategy: validation

Validate before calling

var valid = new[] { "wincredman", "dpapi", "plaintext", "secretservice", "gpg", "keychain", "cache" };
var configured = Environment.GetEnvironmentVariable("GCM_CREDENTIAL_STORE")
    ?? "$(git config --global credential.credentialStore)".Trim();
if (string.IsNullOrWhiteSpace(configured) || !valid.Contains(configured.ToLowerInvariant()))
    throw new InvalidOperationException($"Select a valid credential store; configured='{configured}'");

Try / catch

try
{
    var account = credentialStore.Get(serviceName);
}
catch (Exception ex) when (ex.Message.Contains("No credential store has been selected") || ex.Message.Contains("Unknown credential store"))
{
    // configure GCM_CREDENTIAL_STORE or credential.credentialStore, then retry
}

Prevention

When it happens

Trigger: Any store operation (Name, MaxCredentialSize, GetAccounts, Get, AddOrUpdate, Remove) triggers EnsureBackingStore; it throws when neither GCM_CREDENTIAL_STORE nor credential.credentialStore is set to a recognized store name on the current platform, or the value is an unknown string.

Common situations: Fresh Linux/macOS installs where no credential store was chosen; typos like `credentialStore=windowscred` or `credential.store=plaintext1`; copying Windows config to Linux; removing a previously available store (e.g. secret-service dependencies) so the default no longer resolves.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11). Data as JSON: /api/errors/b06688506818d9bb. Report an issue: GitHub.

Appendix: source

Thrown at src/Core/CredentialStore.cs:139

                    _backingStore = new NullCredentialStore();
                    break;

                default:
                    var sb = new StringBuilder();
                    sb.AppendLine(string.IsNullOrWhiteSpace(credStoreName)
                        ? "No credential store has been selected."
                        : $"Unknown credential store '{credStoreName}'.");
                    _context.Trace2.WriteError(sb.ToString());
                    sb.AppendFormat(
                        "{3}Set the {0} environment variable or the {1}.{2} Git configuration setting to one of the following options:{3}{3}",
                        Constants.EnvironmentVariables.GcmCredentialStore,
                        Constants.GitConfiguration.Credential.SectionName,
                        Constants.GitConfiguration.Credential.CredentialStore,
                        Environment.NewLine);
                    AppendAvailableStoreList(sb);
                    sb.AppendLine();
                    sb.AppendLine($"See {Constants.HelpUrls.GcmCredentialStores} for more information.");
                    throw new Exception(sb.ToString());
            }
        }

        private static string GetDefaultStore()
        {
            if (PlatformUtils.IsWindows())
                return StoreNames.WindowsCredentialManager;

            if (PlatformUtils.IsMacOS())
                return StoreNames.MacOSKeychain;

            // Other platforms have no default store
            return null;
        }

        private static void AppendAvailableStoreList(StringBuilder sb)
        {
            if (PlatformUtils.IsWindows())

View on GitHub (pinned to e8ce762cd0)