GitHub Account Switcher for the terminal — switch git identities instantly, GitKraken-style, from the command line.
╔══════════════════════════════════════════╗
║ ◉ ghswitch GitHub Account Switcher ║
╚══════════════════════════════════════════╝
▸ Switch global profile
↑↓ / j k to navigate · Enter to select · q to quit
██ › work ● active
personal
client-acme
- Arrow-key TUI — navigate profiles like GitKraken's profile switcher
- Per-repo override — apply a profile locally without touching global config
- Full identity stack — manages git config, SSH keys, GPG signing, and gh CLI
- bash 3.2+ compatible — works on macOS (default bash), Linux, and Windows Git Bash / WSL
- Zero dependencies — just bash + git. No npm, no Python, no package manager.
- Direct switch —
ghswitch workwith no menu for scripting and speed
# 1. Download
curl -O https://raw.githubusercontent.com/MadhuS-1605/Github-Profile-Switcher/main/ghswitch.sh
# 2. Make executable
chmod +x ghswitch.sh
# 3. Install globally
sudo cp ghswitch.sh /usr/local/bin/ghswitch
# 4. Verify
ghswitch helpLinux (no sudo)
mkdir -p ~/.local/bin
cp ghswitch.sh ~/.local/bin/ghswitch
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc && source ~/.bashrcWindows (Git Bash)
mkdir -p ~/bin
cp ghswitch.sh ~/bin/ghswitch
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc && source ~/.bashrcImportant: Always use
git@github.com:...(SSH) remote URLs — not HTTPS — so ghswitch's key management takes effect.
# Add your accounts
ghswitch add # prompts: name, email, SSH key, GPG key, gh token, gh host
# See all profiles
ghswitch list
# Launch the TUI switcher
ghswitch
# Or switch directly by name
ghswitch work
ghswitch personal| Command | Description |
|---|---|
ghswitch |
Interactive arrow-key profile switcher |
ghswitch add |
Add a new profile (guided prompts) |
ghswitch list |
List all profiles with active marker |
ghswitch local |
Apply profile to current repo only (git --local) |
ghswitch status |
Show current git identity + gh CLI auth |
ghswitch unset |
Clear global git identity |
ghswitch edit |
Open profiles.conf in $EDITOR |
ghswitch delete |
Remove a profile |
ghswitch <name> |
Switch directly, e.g. ghswitch work |
ghswitch help |
Show help |
| Layer | Config Key | Effect |
|---|---|---|
| Git identity | user.name / user.email |
Commit author, global or per-repo |
| SSH key | core.sshCommand |
Forces specific key with IdentitiesOnly=yes |
| SSH agent | (runtime) | Adds key to agent if socket is active |
| GPG signing | user.signingKey + commit.gpgSign |
Signed commits with your key |
| GitHub Token | credential.helper / gh CLI |
Auth for Git over HTTPS and logs into gh |
| gh CLI | (runtime check) | Verifies gh auth status for the configured host |
Located at ~/.config/ghswitch/profiles.conf. Created automatically on first run.
[work]
name=Jane Doe
email=jane@company.com
ssh_key=~/.ssh/id_ed25519_work
gpg_key=ABCD1234
gh_token=ghp_...
gh_host=github.com
[personal]
name=Jane Doe
email=jane@gmail.com
ssh_key=~/.ssh/id_ed25519_personal
gh_host=github.com
[client-acme]
name=Jane Doe
email=jane@acme.io
ssh_key=~/.ssh/id_ed25519_acme
gh_host=github.comAll fields except name and email are optional.
Generate a separate key per account and add each public key to the respective GitHub account under Settings → SSH and GPG keys.
# Work
ssh-keygen -t ed25519 -C "you@company.com" -f ~/.ssh/id_ed25519_work
# Personal
ssh-keygen -t ed25519 -C "you@gmail.com" -f ~/.ssh/id_ed25519_personal
# Copy public key to clipboard (macOS)
cat ~/.ssh/id_ed25519_work.pub | pbcopyFix permissions if you see SSH warnings:
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519_work # private key
chmod 644 ~/.ssh/id_ed25519_work.pub # public keyApply a profile to a single repo without changing your global identity:
cd ~/projects/client-website
ghswitch local # pick "client-acme" from the menu
git config user.email # confirms local override is activeBlank output / no prompts
bash -x ghswitch add 2>&1 | head -40
# If line 2 shows "set -euo pipefail" — old version is still installed
sudo cp ghswitch.sh $(which ghswitch)403 on git push
# Switch remote from HTTPS to SSH
git remote set-url origin git@github.com:USERNAME/REPO.git
# Clear stale macOS Keychain credentials
git credential-osxkeychain erase <<EOF
protocol=https
host=github.com
EOFWrong key being used
ghswitch status # check active profile and sshCommand
ghswitch edit # fix ssh_key path — must point to private key, not .pubgh CLI warning on switch
gh auth login --hostname github.com| Platform | Shell | Status |
|---|---|---|
| macOS (12+) | bash 3.2 (system) | ✅ Tested |
| macOS (12+) | zsh (via bash shebang) | ✅ Works |
| Ubuntu / Debian | bash 5.x | ✅ Tested |
| Windows | Git Bash (MINGW) | ✅ Works |
| Windows | WSL2 | ✅ Works |
MIT