Git Credential Manager (GCM) supports working with multiple user identities on a single Git hosting service. This page from the official GCM documentation explains how Git handles users, how credentials map to identities, and how to configure per-repository or per-remote accounts.
- **Source**: [Multiple Users - GCM Docs](https://github.com/git-ecosystem/git-credential-manager/blob/main/docs/multiple-users.md)
- **GitHub**: [git-ecosystem/git-credential-manager](https://github.com/git-ecosystem/git-credential-manager)
- **License**: MIT
## Why Multiple Identities?
You might use different accounts on the same Git hosting service for different purposes - one for personal projects, another for open source contributions, and a third for your employer's repositories. Since most Git hosts don't include a "user" part in their HTTPS URLs by default, Git treats them all the same. GCM provides a way to distinguish between these identities.
## How Git Sees Users
Git itself doesn't have a strong concept of "user." The `user.name` and `user.email` config values are embedded into commits but are arbitrary strings - GCM doesn't interact with them at all. The relevant user concept for GCM is the credential user - the identity you authenticate with on a Git hosting provider (e.g., a GitHub username).
## Setting Up Multiple Identities
The key technique is embedding the username into the remote URL using the `user@host` format:
### Fresh Clones
```shell
# Clone with a specific identity
git clone https://
[email protected]/open-source/library.git
# Clone with a different identity
git clone https://
[email protected]/big-company/secret-repo.git
```
### Existing Clones
```shell
# Update an existing remote URL to include the identity
git remote set-url origin https://
[email protected]/open-source/library.git
```
## Setting a Default Account
You can tell GCM to remember which account to use for a particular host or URL using Git configuration:
```shell
# Set a default account for github.com
git config --global credential.https://github.com.username alice
# Clone using a specific account
git clone https://
[email protected]/mona/test
# Update an existing clone
git remote set-url origin https://
[email protected]/mona/test
```
If your account name contains an `@` character, escape it with `%40`:
```shell
git clone https://alice%
[email protected]/test
```
## Platform-Specific Notes
- **GitHub**: Use the `git credential-manager github [list | login | logout]` commands to manage GitHub accounts
- **Azure DevOps**: Has additional complexity around access tokens - see the [Azure DevOps users and tokens](https://github.com/git-ecosystem/git-credential-manager/blob/main/docs/azrepos-users-and-tokens.md) documentation
## About Git Credential Manager
GCM is a secure, cross-platform Git credential helper built on .NET that provides a consistent authentication experience - including multi-factor auth - for Azure DevOps, GitHub, Bitbucket, and GitLab. It replaces both the older .NET Framework-based GCM for Windows and the Java-based GCM for Mac and Linux.