codeworking.org
Search
Developer Skill / Gist

Manage multiple GitHub accounts using the GitHub CLI

By Samuel • Published on 2026-08-19

You can manage multiple GitHub accounts using the GitHub CLI (gh).

The CLI has built-in support for signing into multiple accounts on the same host (e.g., github.com) and switching between them easily.

Here is how to set up and manage both of your accounts.

1. Log In to Both Accounts

You do not need to log out of your first account to add the second one. Simply run the authentication command again:

gh auth login

Follow the interactive prompts to log into your second account. The GitHub CLI will automatically save it alongside your first account instead of overwriting it.

2. Check Your Logged-In Accounts

To see all accounts currently saved on your machine and see which one is currently active, run:

gh auth status

The active account will have an [active] badge next to it.

3. Switch Between Accounts

When you want to run gh commands (like creating a repo, managing PRs, or checking issues) for your other account, switch the active user by running:

gh auth switch --user <username>

Replace <username> with the GitHub username of the account you want to use.


⚠️ Important Note (Git vs. GitHub CLI): The gh auth switch command changes the active account for gh CLI commands (like gh repo create or gh pr list). However, it does not automatically change your local Git identity when you run standard Git commands (like git commit or git push).

To keep your Git commits and SSH connections separated for each account, configure your repositories locally:

  • Set local repository names/emails: In your project folder, set your identity locally so you don’t accidentally commit to a work repo using a personal email:
git config --local user.name "Your Name"
git config --local user.email "your-account-email@example.com"
  • Use SSH Key Configurations: If you use SSH keys, map different host aliases in your ~/.ssh/config file to cleanly separate your keys.
S

Computer Science educator, Software Engineer, Cloud Computing & Cloud Native Architect, and AI/ML Engineer. Founder & Owner of unus.one, softwork.ing, and codeworking.org.

Comments & Discussion