Seamlessly manage multiple Git accounts on a single machine with automatic SSH key management and account detection.
- 🔐 Automatic SSH key management - Generate and manage ED25519 SSH keys per account
- 🎯 Smart account detection - Automatically detect which account to use based on repository
- 🌐 Multi-provider support - Works with GitHub, GitLab, Bitbucket, and self-hosted instances
- 🏢 Custom provider support - Add GitHub Enterprise, GitLab self-hosted, and more
- ⚡ Zero configuration - Works out of the box with sensible defaults
- 🔒 Security-focused - No credential storage, uses SSH keys exclusively
- Prerequisites
- Installation
- Quick Start
- Commands
- Examples
- How It Works
- Custom Providers
- HTTPS vs SSH
- Troubleshooting
- Contributing
- License
- Node.js 14 or higher
- Git installed and configured
gitm requires OpenSSH to be installed. You have several options:
Option 1: Windows 10/11 Built-in OpenSSH (Recommended)
- Open Settings → Apps → Optional Features
- Click "Add a feature"
- Search for "OpenSSH Client" and install it
- Restart your terminal
Option 2: Git for Windows
- Install Git for Windows
- During installation, select "Use Git and optional Unix tools from the Command Prompt"
- This will add
ssh
,ssh-keygen
, andssh-add
to your PATH
Option 3: Use Git Bash
- If you have Git installed, run gitm commands from Git Bash which includes all SSH tools
npm install -g @loopgrid/gitm
# Add personal GitHub account
gitm add personal
# ✔ Name: John Doe
# ✔ Email: john@personal.com
# ✔ Provider: github
# ✔ Username: johndoe
# Add work account
gitm add work
# Interactive authentication setup
gitm auth personal
# This will:
# - Show your SSH public key
# - Guide you to add it to GitHub/GitLab/Bitbucket
# - Test the connection
# Clone with automatic account detection
gitm clone git@github.com:johndoe/project.git
# Or initialize existing repository
cd existing-project
gitm init
Add a new Git account.
gitm add personal
gitm add work --provider gitlab-self # Use custom provider
Options:
--provider <name>
- Specify provider (default: prompts)
List all configured accounts.
gitm list
# personal (John Doe) - john@personal.com [github]
# work (Jane Smith) - jane@company.com [gitlab]
Remove an account and optionally its SSH keys.
gitm remove personal
# ? Are you sure? Yes
# ? Remove SSH keys? Yes
Interactive authentication setup with checklist.
gitm auth work
# Shows SSH key, provides browser links, and guides through setup
Verify account configuration and test SSH connection.
gitm verify personal
# ✓ Account exists
# ✓ SSH key found
# ✓ SSH connection successful
Initialize repository with account auto-detection.
gitm init
# Auto-detects account based on remote URL
# Or prompts to select from matching accounts
gitm init --no-ssh # Keep HTTPS URLs
Options:
--no-ssh
- Don't convert HTTPS URLs to SSH
Set specific account for current repository.
gitm use work
# Updates git config and remote URLs
Clone repository with automatic account setup.
gitm clone git@github.com:company/project.git
gitm clone https://github.com/user/repo.git -d my-folder
Options:
-d, --directory <path>
- Target directory--no-ssh
- Keep HTTPS URLs
Show current repository's account configuration.
gitm status
# Repository: project
# Remote: git@github.com-work:company/project.git
# Account: work (Jane Smith)
# ✓ Using gitm account: work
Add custom provider for self-hosted instances.
gitm provider add gitlab-self
# ? Display name: Company GitLab
# ? Provider type: GitLab (self-hosted)
# ? Domain: gitlab.company.com
# ? SSH port: 22
List all custom providers.
gitm provider list
# gitlab-self:
# Name: Company GitLab
# Host: gitlab.company.com
# SSH Port: 22
Remove a custom provider.
gitm provider remove gitlab-self
Show detailed provider information.
gitm provider show gitlab-self
# Setup
gitm add personal
gitm add work
gitm auth personal
gitm auth work
# Clone personal project
gitm clone git@github.com:johndoe/blog.git
cd blog
gitm status # Shows: Using gitm account: personal
# Clone work project
gitm clone git@github.com:company/app.git
cd app
gitm status # Shows: Using gitm account: work
# Two GitHub accounts
gitm add personal-github
gitm add contractor-github
# Clone automatically detects based on organization
gitm clone git@github.com:personal-org/project.git # Uses personal-github
gitm clone git@github.com:client-org/project.git # Uses contractor-github
# Add custom provider
gitm provider add gitlab-work
# Add account using custom provider
gitm add work --provider gitlab-work
# Clone from self-hosted instance
gitm clone git@gitlab.company.com:team/project.git
cd existing-project
git remote -v # Shows HTTPS URLs
gitm init
# ✔ Auto-detected account: personal
# ✔ Remote URL converted to SSH
git remote -v # Now shows SSH URLs with gitm
Each account gets its own SSH key stored in ~/.ssh/
:
~/.ssh/gitm_personal_github
~/.ssh/gitm_personal_github.pub
~/.ssh/gitm_work_gitlab
~/.ssh/gitm_work_gitlab.pub
gitm creates custom SSH hosts in ~/.ssh/config
:
# gitm: personal
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/gitm_personal_github
IdentitiesOnly yes
# gitm: work
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/gitm_work_github
IdentitiesOnly yes
Repository remotes use custom SSH hosts:
# Instead of: git@github.com:user/repo.git
# gitm uses: git@github.com-personal:user/repo.git
This ensures each repository uses the correct SSH key automatically.
gitm supports any Git hosting service including self-hosted instances.
gitm provider add github-enterprise
# Provider display name: GitHub Enterprise
# Provider type: GitHub Enterprise
# Domain: github.company.com
# SSH port: 22
- GitHub Enterprise
- GitLab (self-hosted)
- Bitbucket Server
- Gitea
- Other (generic)
# Add account with custom provider
gitm add work --provider github-enterprise
# Works automatically with clone/init
gitm clone git@github.company.com:team/project.git
- Multiple identities - Each account has its own SSH key
- No password prompts - SSH keys provide seamless authentication
- Better security - No tokens stored in plain text
While gitm is designed for SSH, you can use HTTPS with limitations:
gitm clone https://github.com/user/repo.git --no-ssh
Limitations:
- Cannot distinguish between multiple accounts on same provider
- Requires manual credential management
- May conflict when switching accounts
cd your-https-repo
gitm init # Offers to convert remotes to SSH
# 1. Verify your setup
gitm verify personal
# 2. Check SSH key is added to provider
gitm auth personal # Re-run setup
# 3. Test SSH directly
ssh -T git@github.com-personal
If you see "Could not add key to ssh-agent" on Windows, the SSH agent service is likely not running.
To fix this permanently:
# 1. Open PowerShell as Administrator
# 2. Enable and start the SSH agent service
Get-Service ssh-agent | Set-Service -StartupType Automatic
Start-Service ssh-agent
# 3. Verify it's running
Get-Service ssh-agent
Alternative: Manually add your key
# If the above doesn't work, manually add your key
ssh-add C:\Users\YourName\.ssh\gitm_personal_github
Note: This is a one-time setup. Once enabled, the SSH agent will start automatically with Windows.
If your network blocks port 22:
# Option 1: Use HTTPS
gitm clone https://github.com/user/repo.git --no-ssh
# Option 2: Configure SSH over HTTPS (port 443)
# Add to ~/.ssh/config:
Host github.com-personal
HostName ssh.github.com
Port 443
User git
IdentityFile ~/.ssh/gitm_personal_github
# Check current configuration
gitm status
# Manually set correct account
gitm use personal
This usually means the SSH key isn't properly configured:
# Re-run authentication
gitm auth personal
# Ensure key is added to Git provider
# Copy key manually if needed:
cat ~/.ssh/gitm_personal_github.pub
Q: Can I use the same email for multiple accounts?
A: Yes, gitm identifies accounts by profile name, not email.
Q: What happens to my existing SSH keys?
A: gitm creates separate keys prefixed with gitm_
and doesn't touch existing keys.
Q: Can I use this with Git GUIs?
A: Yes, gitm configures standard Git settings that work with any Git client.
Q: How do I backup my accounts?
A: Backup ~/.ssh/gitm_*
files and run gitm list
to document your accounts.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
# Install dependencies
npm install
# Run in development
npm run dev
# Build
npm run build
# Run tests
npm test
# Type checking
npm run typecheck
This project is licensed under the MIT License - see the LICENSE file for details.
Built to solve the daily struggle of developers juggling multiple Git accounts.
Note: This project is not affiliated with GitHub, GitLab, or Bitbucket.