Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

naxodev/github-switch

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
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 "you@company.com" --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: you@example.com
  work:
    ssh_key: id_work_rsa
    name: Your Name
    email: you@company.com

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

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.