Skip to content

naxodev/github-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-switch

A CLI tool to quickly switch between multiple GitHub accounts by updating SSH config and Git configuration.

Installation

go install github.com/naxodev/github-switch@latest

Or build from source:

git clone https://github.com/naxodev/github-switch.git
cd github-switch
make install

Quick Start

  1. Initialize the config file:
github-switch init
  1. 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 "[email protected]" --ssh-key "id_work_rsa"
  1. Switch between accounts:
github-switch switch personal
# or use the shorthand
github-switch sw work

Commands

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

Configuration

Accounts are stored in ~/.github-switch.yaml:

accounts:
  personal:
    ssh_key: id_personal_rsa
    name: Your Name
    email: [email protected]
  work:
    ssh_key: id_work_rsa
    name: Your Name
    email: [email protected]

What It Does

When you switch accounts, github-switch:

  1. Updates ~/.ssh/config to use the correct SSH key for github.com
  2. Sets global Git user.name and user.email
  3. Adds the SSH key to your ssh-agent

Prerequisites

  • Go 1.21+ (for installation)
  • SSH keys configured for each GitHub account
  • Git installed

License

MIT License - see LICENSE for details.

About

Github account and ssh keys switcher

Resources

License

Stars

Watchers

Forks

Packages

No packages published