A CLI tool to quickly switch between multiple GitHub accounts by updating SSH config and Git configuration.
go install github.com/naxodev/github-switch@latestOr build from source:
git clone https://github.com/naxodev/github-switch.git
cd github-switch
make install- Initialize the config file:
github-switch init- Add your GitHub accounts:
github-switch add personal
# Follow the prompts to enter your name, email, and SSH key
github-switch add work --name "Your Name" --email "you@company.com" --ssh-key "id_work_rsa"- Switch between accounts:
github-switch switch personal
# or use the shorthand
github-switch sw work| Command | Alias | Description |
|---|---|---|
switch <account> | sw | Switch to a GitHub account |
list | ls | List all configured accounts |
current | Show current Git/SSH configuration | |
add <name> | Add a new account | |
remove <name> | rm | Remove an account |
init | Initialize config file |
Accounts are stored in ~/.github-switch.yaml:
accounts:
personal:
ssh_key: id_personal_rsaname: Your Nameemail: you@example.comwork:
ssh_key: id_work_rsaname: Your Nameemail: you@company.comWhen you switch accounts, github-switch:
- Updates
~/.ssh/configto use the correct SSH key forgithub.com - Sets global Git
user.nameanduser.email - Adds the SSH key to your ssh-agent
- Go 1.21+ (for installation)
- SSH keys configured for each GitHub account
- Git installed
MIT License - see LICENSE for details.