@n44/git-switcher
v1.2.0
Published
Switch and manage multiple GitHub accounts using GitHub CLI.
Downloads
249
Maintainers
Readme
git-switcher
Switch and manage multiple GitHub accounts using GitHub CLI.
Features
- Switch GitHub account with
gh auth switch - Set up Git credential helper with
gh auth setup-git - Save named account aliases for faster switching
- Optionally set global
git user.nameandgit user.email - Validate your local setup with a built-in doctor command
Requirements
- Node.js 18+
- GitHub CLI
- Git
- Logged in at least once with
gh auth login
Installation
Global
npm install -g @n44/git-switcherGlobal update
npm install -g @n44/git-switcher@latestYou can also run:
git-switcher update
git-switcher update --runLocal development
npm install
npm linkCLI names
After global install (or npm link), you can run it in any of the following ways:
git-switcher <command>git switcher <command>gs <command>git s <command>Commands
doctor
git-switcher doctorChecks whether gh and git are available and verifies authentication status.
status
git-switcher statusShows the current active account and gh auth status.
list
git-switcher listLists detected authenticated GitHub accounts.
switch
git-switcher switch <account>Optional flags:
git-switcher switch <account> --setup-git
git-switcher switch <account> --git-name "Your Name" --git-email "[email protected]"setup
git-switcher setupRuns gh auth setup-git.
alias-add
git-switcher alias-add <alias> <account>Optional profile fields:
git-switcher alias-add <alias> <account> --git-name "Your Name" --git-email "[email protected]"aliases
git-switcher aliasesLists all saved alias profiles.
use
git-switcher use <alias>Optional flag:
git-switcher use <alias> --skip-setupalias-rm
git-switcher alias-rm <alias>Removes a saved alias profile.
update
git-switcher updateShows the global npm update command. Use --run to execute it directly.
npmjs.com install command note
The install command shown in the npmjs sidebar is controlled by npm and usually defaults to npm i <package>.
To show global install/update commands (-g) prominently, keep them in this README (npmjs renders this section).
Examples
# direct account switch
gs switch personal --setup-git
# create reusable profile
gs alias-add work john-work --git-name "John" --git-email "[email protected]"
# switch using saved profile
gs use workConfig storage
Alias profiles are stored in:
~/.git-switcher/config.jsonThis package does not store tokens or secrets.
