npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

github-switch

v1.0.1

Published

Switch effortlessly between multiple GitHub and Git accounts with automatic Windows Credential Manager caching.

Readme

GitSwitch (github-switch)

Effortlessly manage and switch between multiple GitHub and Git accounts from your terminal with a single command — including automatic Windows Credential Manager caching & switching.

npm version license node


Features

  • Multi-Account Git Config: Switch git config user.name and user.email instantly.
  • Windows Credential Manager Integration:
    • Automatically captures and caches active GitHub tokens before switching.
    • Executes cmdkey /delete:LegacyGeneric:target=git:https://github.com so git won't reuse the old account.
    • Automatically restores the target account's cached token into Windows Credential Manager so you can git push/git pull without re-authenticating every time.
  • Exact Syntax Match: Supports -uname, -uemail, -token, as well as standard GNU flags.
  • Interactive Terminal UI: Run github switch without arguments for an interactive picker.
  • Security-First: Tokens are stored privately in ~/.gitswitch/credentials.json with restricted permissions and masked in CLI outputs.
  • Command Aliases: Registered under github, gitswitch, git-switch, and github-switch.

Installation

npm install -g github-switch

Or clone and link locally:

cd c:\Projects\github-switch
npm install
npm link

How Credential Caching & Switching Works

When you push or pull over HTTPS, Git Credential Manager stores your GitHub login in Windows Credential Manager under:

Target: LegacyGeneric:target=git:https://github.com

When you switch between accounts with GitSwitch:

Account A (active in Windows Credential Manager)
        │
        ▼  [Run: github switch "Account B"]
1. Reads and safely caches Account A's token/credential in GitSwitch
2. Executes: cmdkey /delete:LegacyGeneric:target=git:https://github.com
3. Updates: git config --global user.name "Account B"
4. Updates: git config --global user.email "[email protected]"
5. Takes Account B's cached token and restores it into Windows Credential Manager!
        │
        ▼
Account B is now active for both git commits AND git push/pull!

When you switch back to Account A (github switch "Account A"):

  • Account B's token is saved to cache.
  • Windows Credential Manager is cleared.
  • Account A's token is restored back into Windows Credential Manager.

CLI Commands

1. View all saved accounts

github list
# alias: github ls

Displays registered accounts, git status, and whether credentials are cached:

Registered GitHub Accounts:
┌──────────────┬───────────────┬───────────────────┬─────────────┬─────────┬──────────────┐
│ Status       │ Username      │ Email             │ Credentials │ SSH Key │ Added / Used │
├──────────────┼───────────────┼───────────────────┼─────────────┼─────────┼──────────────┤
│ Active       │ bytecamp-in   │ [email protected]   │ Cached      │ none    │ used today   │
├──────────────┼───────────────┼───────────────────┼─────────────┼─────────┼──────────────┤
│ -            │ personal-dev  │ [email protected]      │ Cached      │ none    │ added 9/11   │
└──────────────┴───────────────┴───────────────────┴─────────────┴─────────┴──────────────┘

2. Add an account

# Add with username and email
github add -uname "username" -uemail "email"

# Add with token upfront
github add -uname "username" -uemail "email" -token "ghp_yourTokenHere"

3. Switch active account (with credential swap)

github switch "username"
# or by email:
github switch "[email protected]"

Output:

[info] Cached active credential for bytecamp-in
[info] Cleared Windows Credential Manager: cmdkey /delete:LegacyGeneric:target=git:https://github.com
[ok] Switched to GitHub account: personal-dev <[email protected]> [global]
[ok] Restored cached credentials for personal-dev into Windows Credential Manager

Options:

  • github switch (interactive arrow-key selector)
  • github switch "username" --local (switch only inside the current repository)
  • github switch "username" --no-cred (skip modifying Windows Credential Manager)

4. Remove an account

github remove -uname "username"
github remove -uemail "email"

Also removes any cached credentials for that account.


5. View current configuration status

github current

Shows:

  • Global and local repository git config
  • Matching GitSwitch profile
  • Active Windows Credential Manager entry for git:https://github.com

6. Manage Windows Credential Manager & Tokens directly

GitSwitch provides the github cred command:

# Check Windows Credential Manager status & cached tokens
github cred status

# Explicitly save current Windows Credential Manager token to GitSwitch cache
github cred save

# Manually store or update a token for a user
github cred set <username> [token]

# Restore a cached user token into Windows Credential Manager
github cred restore <username>

# Clear GitHub entry from Windows Credential Manager
github cred clear

Testing

npm test

All 21 unit and integration tests run via Vitest:

  • Argument normalization (-uname, -uemail, -token)
  • Configuration store
  • Credential caching & masking
  • CLI integration (switching, credential swapping, cmdkey command calls)

License

MIT © 2026 GitSwitch Contributors