A CLI tool to seamlessly switch between multiple Git and GitHub identities. Manage personal, work, and other profiles with a single command that updates your git config, GitHub CLI auth, and SSH routing all at once.
If you use multiple GitHub accounts (personal, work, open-source org), switching between them is painful. You have to manually:
- Change
git config --global user.nameanduser.email - Run
gh auth switch - Swap SSH keys
git-user handles the global identity switch with one command.
# Download and install
curl -o /usr/local/bin/git-user https://raw.githubusercontent.com/<your-user>/git-user/main/git-user
chmod +x /usr/local/bin/git-user
# Or just copy manually
sudo cp git-user /usr/local/bin/git-user
chmod +x /usr/local/bin/git-user- bash 4.0+
- git
- gh (GitHub CLI) — optional but recommended for auth switching
# 1. Add your profiles
git-user add personal
# → prompts for: name, email, GitHub username, org name / repo owner, SSH key (optional), remote host
git-user add work
# 2. Switch profiles
git-user switch personal
# 3. See what's active
git-user list| Command | Aliases | Description |
|---|---|---|
git-user add <profile> |
Create a new profile interactively | |
git-user switch <profile> |
use, set |
Activate a profile (see below) |
git-user list |
ls |
List all profiles (● = active) |
git-user current |
who, status |
Show the active profile and git config |
git-user edit <profile> |
Modify an existing profile | |
git-user remove <profile> |
rm, delete |
Delete a profile (with confirmation) |
git-user help |
--help, -h |
Show help message |
git-user version |
--version, -v |
Print version |
When you run git-user switch <profile>, it performs four actions:
- Git config — Sets
user.nameanduser.emailglobally - GitHub CLI auth — Runs
gh auth switchto the profile's account (promptsgh auth loginif not yet authenticated) - SSH alias — If the profile has an SSH key configured, creates or updates a managed SSH host alias and activates global Git URL rewrites so existing
git@github.com:owner/repo.gitremotes use that profile's key. If not, it clears any previous managed SSH routing. - Remote owner — If you're inside a git repo and it has an
origin, updates the owner part to the profile's configured org name or repo owner. This defaults to the profile's GitHub username.
$ git-user switch work
Switching to profile: work
✔ git config → John Smith <john@company.com>
✔ gh auth → switched to @john-company
✔ SSH alias → git-user-work-github-com (~/.ssh/id_ed25519_work)
✔ remote origin → git@github.com:megacorp/company-api.git
✔ Switched to 'work'
All profiles are stored in ~/.git_user.conf as a simple key-value format:
# ~/.git_user.conf
personal.name=John Doe
personal.email=john@gmail.com
personal.gh_user=johndoe
personal.org_name=johndoe
personal.remote_host=github.com
work.name=John Smith
work.email=john@company.com
work.gh_user=john-company
work.org_name=megacorp
work.ssh_key=~/.ssh/id_ed25519_work
work.remote_host=github.com
_active=personal| Field | Required | Description |
|---|---|---|
name |
✔ | Git author name (user.name) |
email |
✔ | Git author email (user.email) |
gh_user |
✔ | GitHub username for gh CLI auth |
org_name |
Repo owner to use for origin updates. Defaults to gh_user. |
|
ssh_key |
Path to SSH private key used for the managed SSH alias | |
remote_host |
GitHub host for gh auth and the SSH alias (default: github.com) |
Override the config path with the GIT_USER_CONF environment variable:
export GIT_USER_CONF="$HOME/.config/git-user/profiles.conf"
git-user listOverride the SSH config path with GIT_USER_SSH_CONFIG:
export GIT_USER_SSH_CONFIG="$HOME/.config/ssh/git-user-config"
git-user switch personalForce keychain-style SSH directives for managed aliases with GIT_USER_SSH_USE_KEYCHAIN=1:
export GIT_USER_SSH_USE_KEYCHAIN=1
git-user switch personal$ git-user add personal
Full name: John Doe
Email: john@gmail.com
GitHub username: johndoe
Org name / repo owner [johndoe]:
SSH key path (optional): ~/.ssh/id_ed25519
Remote host (optional) [github.com]:
✔ Profile 'personal' added successfully!
$ git-user add work
Full name: John Smith
Email: john.smith@megacorp.com
GitHub username: john-megacorp
Org name / repo owner [john-megacorp]: megacorp
SSH key path (optional): ~/.ssh/id_ed25519_work
Remote host (optional) [github.com]:
✔ Profile 'work' added successfully!$ cd ~/projects/company-api
$ git-user switch work
# → git config, gh auth, SSH alias routing, and origin owner all updated
$ git commit -m "feat: add endpoint"
# commit is authored as John Smith <john.smith@megacorp.com>$ git-user list
Profiles (~/.git_user.conf)
● personal John Doe <john@gmail.com> @johndoe
work John Smith <john.smith@megacorp.com> @john-megacorpSet remote_host to your enterprise instance:
$ git-user add enterprise
Full name: John Smith
Email: john@corp.internal
GitHub username: jsmith
Org name / repo owner [jsmith]: engineering
SSH key path (optional):
Remote host (optional) [github.com]: github.corp.internal
✔ Profile 'enterprise' added successfully!- Shell alias — Add
alias gu="git-user"to your.bashrc/.zshrcfor faster switching. - Multiple SSH keys — Each profile can point to a different SSH key.
switchmanages per-profile SSH host aliases in~/.ssh/configand updates Git's globalurl.*.insteadOfrules so standard GitHub SSH remotes follow the active profile. - Passphrase caching — On macOS, managed SSH aliases include
AddKeysToAgent yesandUseKeychain yesso switched keys can be cached. SetGIT_USER_SSH_USE_KEYCHAIN=1to force those directives in environments that support them. - Edit the config directly — The
.git_user.conffile is human-readable; feel free to edit it by hand.
MIT