Coding

Git Credential Manager: Install, Set Up and Fix Sign-In

Git Credential Manager (GCM) is a Git credential helper that signs you in to GitHub, GitLab, Bitbucket and Azure DevOps over HTTPS and stores the result securely, so you are not asked for a password on every push. On Windows it ships with Git for Windows; elsewhere install it, run git-credential-manager configure, and pick a credential store.

Check whether it is already active with git config credential.helper. If the output is manager, Git is using it. To assign it by hand, run git config --global credential.helper manager.

What Git Credential Manager does

According to the project README, GCM is a secure Git credential helper built on .NET that runs on Windows, macOS and Linux. It aims to give one consistent sign-in experience, including multi-factor authentication, across the major source control hosts. It supports Azure DevOps, Azure DevOps Server, Bitbucket, GitHub and GitLab. It replaced the older .NET Framework-based Windows version and the Java-based Mac and Linux version.

Git calls GCM for you. You normally never run it directly, apart from the setup commands below. For a GitHub HTTPS remote, the first push opens a sign-in flow, GCM stores the resulting credential, and later pushes reuse it. If you use SSH remotes instead, GCM is not involved; see how to add an SSH key to GitHub.

Install it on Windows

The preferred route is Git for Windows. GCM is bundled, and in the installer it is the default credential helper choice. Nothing else to install.

A standalone installer also exists in two variants:

  • User (gcmuser-win*): no administrator rights, applies to the current user only.
  • System (gcm-win*): needs administrator rights, applies to all users and updates the system-wide Git configuration.

A standalone install overrides the GCM bundled with Git for Windows, even if the bundled version is newer. To uninstall the standalone version, open Settings, go to Apps, select "Git Credential Manager" and click Uninstall.

Install it on macOS

The documented preferred method is Homebrew:

brew install --cask git-credential-manager

Upgrade with brew upgrade --cask git-credential-manager and remove with brew uninstall --cask git-credential-manager. A package installer from the project's releases page also works.

Install it on Linux

Every Linux distribution needs extra configuration, because the project cannot guarantee a suitable credential store exists. The preferred method is the .NET tool, which needs .NET SDK 10.0 as of the current install docs:

dotnet tool install -g git-credential-manager
git-credential-manager configure

After installing, add the .NET tools directory to your PATH using the instructions the installer prints. Other documented options are a Debian package (sudo dpkg -i <path-to-package>, then git-credential-manager configure), a tarball extracted into /usr/local/bin, and an install-from-source script.

What configure does

git-credential-manager configure writes the settings that make Git use GCM into your user-level Git configuration (~/.gitconfig). With --system it changes the system-level configuration (/etc/gitconfig) instead. git-credential-manager unconfigure reverses it, and the docs say to run it before uninstalling on Linux.

Choose a credential store

The store decides where saved secrets live. Set it with:

git config --global credential.credentialStore <value>

The environment variable GCM_CREDENTIAL_STORE does the same job, and GCM environment variables take precedence over configuration options.

ValuePlatformNotes
wincredmanWindowsWindows Credential Manager. Default on Windows. Does not work over a network or SSH session.
dpapiWindowsDPAPI protected files in %USERPROFILE%\.gcm\dpapi_store.
keychainmacOSDefault on macOS. Uses the default keychain, usually login.
secretserviceLinuxUses libsecret. Needs a D-Bus session bus and a provider such as GNOME Keyring or KWallet.
gpgmacOS, LinuxNeeds gpg, pass, a GPG key pair and a store created with pass init.
cachemacOS, LinuxIn memory only. Default timeout 900 seconds, set with credential.cacheOptions.
plaintextAllUnencrypted files in ~/.gcm/store. Not secure.
noneAllPassthrough: stores nothing.

On Linux the default is unset, so Git will fail to save credentials until you pick one. On a desktop with GNOME Keyring or KWallet, secretservice is the usual choice. On a headless server, gpg works but needs a TTY-capable pinentry. Avoid plaintext except for throwaway machines.

Control how the sign-in window appears

  • git config --global credential.interactive false disables prompts. When interaction is needed and disabled, GCM returns an error. Useful for scripts.
  • git config --global credential.msauthFlow devicecode picks the Microsoft sign-in method. Values are auto (default), embedded, system and devicecode. This applies to Microsoft accounts such as Azure DevOps.

Clear a saved credential

The GCM FAQ has no dedicated entry on erasing stored credentials, but Git itself can ask every configured helper to forget one. The git credential reject action sends a credential description to the helpers, which may erase matching stored credentials. Feed it the protocol and host, ending with a blank line:

printf 'protocol=https\nhost=github.com\n\n' | git credential reject

That is the Git-documented input format; the one-liner is an illustration built from it. On Windows, the equivalent manual route with the default store is opening Windows Credential Manager from the Start menu and removing the git:https://github.com entry. I have not verified that entry name against GCM's documentation, so check the name you see in your own list.

To invalidate the tokens themselves, revoke GCM in your host's settings. For GitHub.com, the FAQ says revoking Git Credential Manager under your authorized OAuth apps invalidates any tokens GCM created, and GCM asks for consent again on the next access.

If sign-in still fails

  • Plain HTTP remote. GCM will not send credentials over plain HTTP for supported hosts. Check git remote -v and use an https:// URL.
  • Linux credential store errors. You must select and configure a store; see the table above.
  • Behind a proxy. Configure Git and GCM for the proxy, as described in the project's network configuration doc.
  • Azure DevOps (dev.azure.com). Set credential.useHttpPath to true. Inside WSL, set it inside WSL.
  • Slow first run. GCM probes on-premises hosts to detect the provider. Results are cached, and you can set the provider explicitly to skip the probe.
  • Still unexplained. Set the GCM_TRACE environment variable to collect a trace log, as the FAQ suggests, before filing an issue. Remove tokens and passwords from the log first.

Frequently asked questions

Is Git Credential Manager installed with Git for Windows?
Yes. Git for Windows bundles Git Credential Manager, and it is the default credential helper choice in the installer. A separate standalone installer also exists, and installing it overrides the bundled copy even when the bundled version is newer.
Which hosts does Git Credential Manager support?
According to its README, it supports Azure DevOps, Azure DevOps Server, Bitbucket, GitHub and GitLab. It handles HTTPS remotes only: it will not send credentials over plain HTTP for supported hosts.
Where does Git Credential Manager store my credentials?
It depends on the credential store. The defaults are Windows Credential Manager on Windows and the login keychain on macOS. On Linux no store is selected by default, so you must choose one, for example secretservice or gpg.
How do I switch from Git Credential Manager back to the default Git behavior?
Run git-credential-manager unconfigure. According to the FAQ, this removes the settings that configure added to your Git configuration. Add --system to act on the system-level configuration instead of your user-level one.

Sources