Git Credential Manager (GCM)

The Git Credential Manager (GCM) is a credential helper for Git that securely stores and manages Git credentials. It integrates with the system's credential storage, such as the GNOME Keyring or libsecret on Linux, Windows Credential Manager on Windows, and macOS Keychain. GCM is recommended for securely managing your Git credentials, as it avoids storing credentials in plain text and leverages system security features to encrypt them.

1. Why Use Git Credential Manager (GCM)?

  • Secure Storage: GCM stores credentials in the system's secure credential storage (e.g., GNOME Keyring or libsecret), ensuring they’re encrypted.

  • User Convenience: Once configured, GCM saves credentials, so you won’t be prompted every time you interact with a Git repository.

  • Cross-Platform: GCM works consistently across Windows, macOS, and Linux.

  • Token Support: It supports storing personal access tokens (PATs) for services like GitHub, GitLab, and Bitbucket, which are often more secure than using passwords.

2. How to Install Git Credential Manager (GCM) on Ubuntu

GCM is available for installation on Ubuntu through the package git-credential-manager-core. Here’s a step-by-step guide:

  • Step 1: Update the package list to ensure you have the latest information on available packages:

    sudo apt update
  • Step 2: Install the GCM package:

    sudo apt install git-credential-manager-core
  • Step 3: Configure Git to use GCM as the credential helper:

    git config --global credential.helper manager-core
    • The --global flag applies this setting across all repositories for the current user.

3. Configuring GCM for the First Time

After installing and configuring GCM, you may need to initialize it by running a Git command that requires authentication (e.g., git clone, git pull, or git push). During this process, GCM will prompt you for your username and password or personal access token (PAT), depending on the service you’re accessing.

  • Example:

  • Prompt for Credentials:

    • When prompted, enter your GitHub (or other service’s) username and personal access token. GCM will save these credentials securely using Ubuntu's credential manager (such as GNOME Keyring or libsecret).

4. Using GCM with Different Git Services

GCM supports multiple Git services, including:

  • GitHub

  • GitLab

  • Bitbucket

  • Azure Repos

During the first interaction with any of these services, GCM will prompt for the relevant credentials (PAT or password) and store them in your system’s credential storage.

5. Verifying GCM Configuration

To confirm that Git is using GCM as the credential helper, run:

The output should show manager-core, confirming that GCM is configured as the credential helper.

6. Managing and Clearing Stored Credentials

  • To View Stored Credentials: GCM integrates with the system keychain, so you can view stored credentials through your system’s credential manager (e.g., GNOME Keyring).

  • To Clear Specific Credentials: If you need to reset or remove stored credentials, you can do so directly from the keyring or by running:

    • This will prompt you for details about the credentials you want to remove (e.g., username and URL for the repository).

  • To Clear All Credentials: Run:

7. Testing GCM Configuration

After configuration, you can test that GCM is storing credentials securely by performing an action that requires authentication, like cloning a repository. You should only be prompted for credentials the first time, after which GCM will handle future authentications automatically.

Summary of Commands

Command
Purpose

sudo apt update

Update package list.

sudo apt install git-credential-manager-core

Install GCM on Ubuntu.

git config --global credential.helper manager-core

Set GCM as the credential helper for Git globally.

git credential-manager-core erase

Erase specific credentials from GCM.

This setup provides secure, convenient, and reliable storage for your Git credentials on Ubuntu. Let me know if you need help with specific services or additional customization!

Last updated