Git Credential Manager for Multiple Accounts: The Complete Setup Guide
Configuring git credential manager multiple accounts is one of those tasks that seems simple until you’re 30 minutes deep in conflicting Stack Overflow answers. Whether you’re pushing to a personal GitHub and a company GitLab, or managing repos across multiple GitHub organizations with different accounts, Git’s credential management needs deliberate configuration to work smoothly.
This guide walks you through every credential management approach — from Git Credential Manager (GCM) to SSH keys to personal access tokens — with tested configurations for the most common multi-account scenarios.
Understanding Git’s Credential System
How Git Stores Credentials
When you push to a remote repository over HTTPS, Git needs your username and password (or token). Without a credential helper, Git asks for these every time. Credential helpers store and retrieve these credentials automatically.
Available Credential Helpers
| Helper | OS | Storage | Multi-Account |
|---|---|---|---|
| Git Credential Manager (GCM) | All | OS keychain | Yes (with config) |
| macOS Keychain | macOS | Keychain Access | Limited |
| Windows Credential Manager | Windows | Windows Credential Store | Limited |
| libsecret | Linux | GNOME Keyring | Limited |
| cache | All | In-memory (temporary) | No |
| store | All | Plain text file | No (insecure) |
The Multi-Account Problem
Default credential helpers store credentials per hostname. Since GitHub, GitLab, and Bitbucket each use a single hostname (github.com, gitlab.com, bitbucket.org), the helper stores only one set of credentials per platform. When you push to a repo owned by your second account, the helper sends the first account’s credentials — and the push fails with a 403 error.
Git Credential Manager (GCM): The Recommended Solution
What GCM Is
Git Credential Manager (GCM) is Microsoft’s cross-platform credential helper that replaces the older Git Credential Manager for Windows and Git Credential Manager Core. It’s the most capable option for multi-account workflows because it supports per-URL credential storage and OAuth-based authentication.
Installing GCM
macOS
# Via Homebrew
brew install git-credential-manager
# Or via .pkg installer from GitHub releases
# https://github.com/git-ecosystem/git-credential-manager/releases
Windows
# Bundled with Git for Windows (2.39+)
# Or install standalone:
winget install git-credential-manager
Linux
# Debian/Ubuntu
wget https://github.com/git-ecosystem/git-credential-manager/releases/latest/download/gcm-linux_amd64.deb
sudo dpkg -i gcm-linux_amd64.deb
# Or via .tar.gz
tar xvf gcm-linux_amd64.tar.gz
sudo ./install.sh
Configuring GCM for Multiple Accounts
Enable Path-Based Credential Storage
The key setting for multi-account support is useHttpPath. This tells GCM to store separate credentials per repository path, not just per hostname:
# Enable for all of GitHub
git config --global credential.https://github.com.useHttpPath true
# Enable for all of GitLab
git config --global credential.https://gitlab.com.useHttpPath true
# Enable for Bitbucket
git config --global credential.https://bitbucket.org.useHttpPath true
With useHttpPath enabled, GCM stores separate credentials for github.com/personal/repo and github.com/company/repo.
Setting Default Usernames per Path
# Personal repos (GitHub username: personal-user)
git config --global credential.https://github.com/personal.username personal-user
# Work repos (GitHub username: work-user)
git config --global credential.https://github.com/company-org.username work-user
Per-Repository Username
For more granular control, set the username per repository:
cd ~/work/project
git config credential.username work-user
cd ~/personal/project
git config credential.username personal-user
Method 2: SSH Keys (The Classic Approach)
Why SSH Is Often Preferred
SSH key authentication doesn’t use Git’s credential system at all. Each key maps to exactly one account, and the SSH config file provides clean per-host routing. Many developers prefer SSH because it’s simpler to reason about for multi-account setups.
Complete SSH Setup for Multiple Accounts
Generate Keys
# Personal GitHub account
ssh-keygen -t ed25519 -C "personal@email.com" -f ~/.ssh/github_personal
# Work GitHub account
ssh-keygen -t ed25519 -C "work@company.com" -f ~/.ssh/github_work
# GitLab account
ssh-keygen -t ed25519 -C "dev@email.com" -f ~/.ssh/gitlab_personal
Configure SSH Config
# ~/.ssh/config
# Personal GitHub
Host github-personal
HostName github.com
User git
IdentityFile ~/.ssh/github_personal
IdentitiesOnly yes
# Work GitHub
Host github-work
HostName github.com
User git
IdentityFile ~/.ssh/github_work
IdentitiesOnly yes
# Personal GitLab
Host gitlab-personal
HostName gitlab.com
User git
IdentityFile ~/.ssh/gitlab_personal
IdentitiesOnly yes
Clone and Configure Remotes
# Clone using host alias
git clone git@github-personal:myuser/repo.git
git clone git@github-work:company/repo.git
git clone git@gitlab-personal:myuser/project.git
# For existing repos, update the remote
cd existing-work-repo
git remote set-url origin git@github-work:company/repo.git
Method 3: Personal Access Tokens (PATs)
Token-Based Authentication
GitHub, GitLab, and Bitbucket all support personal access tokens as password replacements. For multi-account setups, you can store different tokens per repository:
Creating Tokens
- GitHub: Settings → Developer Settings → Personal Access Tokens → Generate New Token
- GitLab: Preferences → Access Tokens → Create Personal Access Token
- Bitbucket: Personal Settings → App Passwords → Create App Password
Using Tokens with GCM
When GCM prompts for credentials (with useHttpPath enabled), enter your username and use the PAT as the password. GCM stores the token in your OS keychain for future use.
Using Tokens in URL (Not Recommended for Security)
# Embedding token in remote URL (stored in .git/config - insecure)
git remote set-url origin https://personal-user:ghp_TOKEN@github.com/personal/repo.git
Warning: Embedding tokens in URLs stores them in plain text in .git/config. Use GCM or SSH keys instead.
Method 4: Git Config Conditional Includes
Directory-Based Identity
Combine credential management with automatic author identity using Git’s conditional includes:
# ~/.gitconfig
[user]
name = Personal Name
email = personal@email.com
# Work directory overrides
[includeIf "gitdir:~/work/"]
path = ~/.gitconfig-work
# Freelance directory overrides
[includeIf "gitdir:~/freelance/"]
path = ~/.gitconfig-freelance
# ~/.gitconfig-work
[user]
name = Work Name
email = work@company.com
[credential "https://github.com"]
username = work-user
# ~/.gitconfig-freelance
[user]
name = Freelance Name
email = freelance@email.com
[credential "https://gitlab.com"]
username = freelance-user
This ensures that both the commit author identity and the push credentials are correct based on where you clone the repo.
Platform-Specific Configuration
GitHub Multi-Account
| Method | Authentication | Complexity | Best For |
|---|---|---|---|
| SSH host aliases | SSH keys | Medium | Most developers |
| GCM + useHttpPath | PAT/OAuth | Low | HTTPS-required environments |
| GitHub CLI (gh) | OAuth | Low | CLI-heavy workflows |
| GitHub App | Installation token | High | CI/CD automation |
GitLab Multi-Account
GitLab’s SSH key management is similar to GitHub. One difference: GitLab supports deploy tokens at the project or group level, which are useful for CI/CD pipelines that need to access repos from multiple accounts.
Bitbucket Multi-Account
Bitbucket uses “App Passwords” instead of PATs. The setup is identical: enable useHttpPath in GCM and use the App Password as the password credential. Bitbucket also supports SSH keys with the same host-alias approach.
Managing Web UI Sessions for Multiple Git Accounts
Browser Profile Separation
CLI credentials handle push/pull, but you also need to access GitHub’s web UI (pull requests, issues, settings) for multiple accounts. Options:
- Chrome profiles — create a profile per Git account, each logged into the respective platform
- Firefox Multi-Account Containers — container tabs per account within a single Firefox window
- Cloud browser isolation — for accounts requiring complete separation, session isolation platforms provide unique environments per account
Troubleshooting Common Issues
Issue: “remote: Permission to user/repo.git denied to wrong-user”
Cause: Git is sending credentials for the wrong account.
Fix: Enable useHttpPath and clear cached credentials:
# Clear cached credentials for GitHub
git credential reject <<EOF
protocol=https
host=github.com
EOF
# Or clear the OS keychain entry manually
# macOS: Keychain Access → search "github.com" → delete
# Windows: Credential Manager → Windows Credentials → search "github"
# Linux: seahorse → search "github"
Issue: SSH Uses the Wrong Key
Cause: SSH agent offers all loaded keys, and GitHub accepts the first valid one.
Fix: Add IdentitiesOnly yes to your SSH config and use host aliases.
Issue: Commits Show Wrong Author
Cause: Global user.name and user.email override per-repo settings.
Fix: Use conditional includes or explicitly set identity per repo:
git config user.name "Correct Name"
git config user.email "correct@email.com"
# Amend the last commit to fix author
git commit --amend --reset-author
Issue: GCM Keeps Opening Browser for Auth
Cause: GCM defaults to OAuth browser flow.
Fix: Set GCM to use PATs instead:
git config --global credential.gitHubAuthModes pat
Best Practices for Multi-Account Git Credentials
Security
- Use SSH Ed25519 keys — stronger than RSA, smaller key size
- Passphrase-protect SSH keys — adds a layer of protection if the key file is compromised
- Use fine-grained PATs — GitHub’s fine-grained tokens let you limit access per repository
- Rotate credentials regularly — set PAT expiration dates and replace keys annually
- Never commit credentials — add
.envand credential files to.gitignore
Organization
- Consistent directory structure —
~/personal/,~/work/,~/freelance/ - Name SSH keys descriptively —
id_ed25519_github_personalnotid_rsa_2 - Document your setup — create a dotfiles repo with your Git and SSH configs
- Use secure browsing practices when managing tokens and keys through web UIs
Recommended Setup by Scenario
| Scenario | Recommended Method | Why |
|---|---|---|
| Personal + Work GitHub | SSH keys + conditional includes | Clean separation, automated identity |
| Multiple GitLab instances | SSH keys (one per instance) | Different hostnames make it simple |
| GitHub + GitLab + Bitbucket | SSH keys (different hostnames) | No conflict since hosts differ |
| Enterprise (HTTPS required) | GCM + useHttpPath + conditional includes | Compliant with corporate policies |
| CI/CD multi-account | Deploy keys or GitHub Apps | Scoped access, no personal credentials |
How Send.win Helps You Master Git Credential Manager Multiple Accounts
Send.win makes Git Credential Manager Multiple Accounts simple and secure with powerful browser isolation technology:
- Browser Isolation – Every tab runs in a sandboxed environment
- Cloud Sync – Access your sessions from any device
- Multi-Account Management – Manage unlimited accounts safely
- No Installation Required – Works instantly in your browser
- Affordable Pricing – Enterprise features without enterprise costs
Try Send.win Free – No Credit Card Required
Experience the power of browser isolation with our free demo:
- Instant Access – Start testing in seconds
- Full Features – Try all capabilities
- Secure – Bank-level encryption
- Cross-Platform – Works on desktop, mobile, tablet
- 14-Day Money-Back Guarantee
Ready to upgrade? View pricing plans starting at just $9/month.
FAQ — Git Credential Manager Multiple Accounts
Can I use both SSH and HTTPS for different accounts?
Yes. You can use SSH for your personal account and HTTPS with GCM for your work account (or vice versa). Git determines the protocol based on the remote URL format (git@github.com:... for SSH, https://github.com/... for HTTPS).
Will this setup work with VS Code?
Yes. VS Code uses your Git configuration directly. If you set up SSH keys, GCM, or conditional includes correctly, VS Code will use the right credentials when you push, pull, or clone. The VS Code terminal also respects your SSH config.
How do I switch between accounts quickly?
With the SSH host alias approach, you don’t need to “switch” — each repository uses its configured remote URL, which maps to the correct key automatically. For the GitHub CLI (gh), use gh auth switch to change the active account.
Does this work with GitHub Desktop?
GitHub Desktop supports one GitHub account at a time. You can sign out and sign in with a different account, but it doesn’t support simultaneous multi-account access. For multi-account workflows, the command line with SSH keys is more capable.
What about signed commits with multiple accounts?
Each Git account may need its own GPG or SSH signing key. Add the signing key configuration to your conditional includes so the correct key is used based on the directory. Verify the signing key is registered with the corresponding GitHub/GitLab account.
🏆 Verdict: Best Git Credential Setup for Multiple Accounts
For most developers, SSH keys with host aliases + Git conditional includes is the most reliable and maintainable solution. It handles authentication and author identity automatically based on directory structure, requires no credential switching, and works seamlessly across all Git clients and editors. If your organization mandates HTTPS, GCM with useHttpPath enabled is the best alternative — it stores per-path credentials securely in your OS keychain.
Related Products & Resources
- Multiple Amazon Accounts Multi Account Management Guide 2026
- Multiple Amazon Accounts Complete Guide To Safe Multi Store Operations 2026
- Managing Multiple Accounts Multi Account Management Guide 2026
- Best Browser For Multiple Accounts Expert Review Comparison 2026
- How I Manage 10 Social Media Accounts Without Losing My Mind Sendwin Changed Everything
