How to Use Multiple GitHub Accounts on One Computer using GitHub CLI

Use GitHub CLI to manage multiple GitHub accounts on one machine — no SSH keys or PATs. Per‑repo identity, fast account switching, hassle‑free cloning.

August 13, 2025
8 min read
github-cli-multiple-accounts
github-cli
multiple-accounts
git-config
developer-setup
productivity


If you've ever juggled a personal GitHub account and a company or client GitHub account on the same laptop, you've probably fallen down the rabbit hole of SSH keys, config files, and personal access tokens. That works — but it's fiddly, hard to remember, and easy to break when you switch machines.


Here's the simpler way I now recommend: use GitHub CLI (gh). It lets you:


Authenticate once per account (browser-based OAuth)
Switch which account is “active” in a single command
Configure per‑repository author identity with git config --local
Clone the right repository from the right account without thinking about tokens or SSH

In short: no SSH keys, no PATs (Personal Access Tokens) — just gh.


Why GitHub CLI over SSH and PATs (Personal Access Tokens)?


Let me be honest: I used to maintain multiple SSH keys with ~/.ssh/config, then switched to PATs (Personal Access Tokens) for HTTPS. Both approaches work, but they add a maintenance burden and are brittle across machines. With gh, authentication happens via your browser and the token lives securely in your OS keychain. Swapping accounts becomes muscle memory rather than a mini‑tutorial every time.


The goal is frictionless context switching: pick the account, set the repo identity, do the work.

Side note: GitHub Desktop doesn’t support multiple signed‑in accounts for some reason (at least at the time of this writing). If you juggle personal and work profiles, GitHub CLI gives you first‑class multi‑account switching via gh auth switch.

Setup


You'll set up two (or more) GitHub accounts on a single device and switch between them in seconds:


1.
Log in to each account with gh auth login
2.
Tell Git to use gh for credentials (gh auth setup-git)
3.
For each repository, set user.name and user.email locally
4.
Switch active account with gh auth switch
5.
Clone from the correct account with gh repo clone

Short on time? Grab Quick start — copy/paste and go. Want the why behind each command? Detailed guide walks through the same flow with context and gotchas.


Quick start (copy/paste)


First install GitHub CLI


bash
# 1) Log into Account A
gh auth login
# Follow the prompts: GitHub.com → HTTPS → Login with a web browser

# 2) Make sure Git asks gh for credentials
gh auth setup-git

# 3) (Optional) Log into Account B too
gh auth login

# 4) See which accounts are configured
gh auth status

# 5) Switch the active account (by username)
gh auth switch -u your-company-username

# 6) Clone a repo while the right account is active
gh repo clone owner/repo
#             ^ Sidenote: you can also just enter the repository url 
#             instead of owner/repo format

# 7) Inside each repo, set the author identity (local only)
git config --local user.name "Your Name"
git config --local user.email "[email protected]"

That’s the entire workflow. No ~/.ssh/config gymnastics.


Detailed guide


Step 1 — Install and log in with GitHub CLI


Install GitHub CLI (gh) following the official instructions for your OS. Then run:


bash
gh auth login

Pick:


GitHub.com
HTTPS
Login with a web browser

CLI will open your browser, you confirm, and you’re done. Repeat for each account you use (personal, work, client). You can verify your setup:


bash
gh auth status

You should see all authenticated accounts listed for github.com.


Step 2 — Let Git use gh for credentials


Make Git use gh for HTTPS so pushes use the right account:


bash
gh auth setup-git

This configures Git’s credential helper so GitHub HTTPS operations delegate to gh under the hood. If you ever used PATs before, this avoids storing or rotating them manually.


Step 3 — Per‑repository author identity (the important bit)


Your Git author identity should reflect where the code belongs. Keep it local to each repository so global settings never leak between personal and company projects.


bash
cd /path/to/your/repo

# Set author identity only for THIS repo
git config --local user.name  "Your Name"
git config --local user.email "[email protected]"

# Verify
git config --get user.name
git config --get user.email

This affects commit metadata only; it doesn’t change which account you’re authenticated as. Authentication is handled by gh (next section).


Tip: Keep global identity empty or set it to your personal profile; rely on --local for company/client repos.

Step 4 — Switch the active GitHub account


When you need to move between accounts, switch the active one:


bash
# List status (who’s active now?)
gh auth status

# Switch by username for github.com
gh auth switch -u your-company-username

# Or interactively if you prefer
gh auth switch

From now on, your gh commands and GitHub HTTPS operations (thanks to gh auth setup-git) use the selected account’s token.


Step 5 — Clone repos from the right account


Two easy options:


1) Use gh to clone while the correct account is active:


bash
gh auth switch -u personal-username
gh repo clone myusername/dotfiles
#             ^ Sidenote: you can also just enter the repository url 
#             instead of owner/repo format

gh auth switch -u work-username
gh repo clone my-company/internal-tool
#             ^ Sidenote: you can also just enter the repository url 
#             instead of owner/repo format

2) Or use standard git clone over HTTPS after gh auth setup-git:


bash
gh auth switch -u work-username
git clone https://github.com/my-company/internal-tool.git

Either way, the credential comes from the active gh session — not from an SSH key or a PAT you have to manage.


Reference: Commands you’ll actually use


TaskCommand
Log in to an accountgh auth login
See which accounts are authenticatedgh auth status
Show only the currently active accountgh auth status -a
Make Git use gh for HTTPSgh auth setup-git
Switch active accountgh auth switch -u <username>
Clone a repo with the active accountgh repo clone owner/repo
Set repo author identitygit config --local user.name "Name" + git config --local user.email "[email protected]"
Check current repo author namegit config --get user.name
Check current repo author emailgit config --get user.email

Common gotchas (and fixes)


Wrong author on commits: Set user.name and user.email with --local inside each repo. Verify with git log --format='%an <%ae>' -1.
Git still asks for a password: Run gh auth setup-git so Git uses gh as the credential helper for GitHub over HTTPS.
You cloned while the wrong account was active: Switch accounts with gh auth switch -u <username> and re‑clone, or update the remote if appropriate.
Signing commits (optional): If your org requires signed commits, configure GPG or SSH signing independently of auth; the steps above still apply.
Enterprise hosts: For GitHub Enterprise, gh supports multiple hosts. Use gh auth login and gh auth switch with the appropriate --hostname or choose it interactively.

My Recommendation


When to Use This Setup


Perfect for:

You work across personal and company/client repos on one machine
You prefer HTTPS over SSH and don’t want to manage keys
You want commits to carry the correct identity per project
You need fast, low‑friction account switching multiple times a day

Skip this for:

You already have a polished SSH setup and love it
You need machine‑user automation without an interactive browser flow (consider a dedicated bot account + PAT/Actions)
Organization mandates SSH-only access

FAQ


Does this store a PAT under the hood?

No. gh uses an OAuth token scoped via your browser login and stores it securely (Keychain on macOS, etc.). You don’t create or rotate PATs yourself.


Will this break if I change laptops?

Just reinstall gh, run gh auth login for your accounts, and gh auth setup-git. Your per‑repo user.name/user.email live in each repository, so they carry with the repo.


Can I use this alongside SSH?

Yes. You can mix approaches per repo, but the point of this guide is that you don’t need SSH for multiple accounts if you don’t want it.


Summary


Managing multiple GitHub accounts doesn’t have to mean wrangling SSH keys or memorizing PATs. With GitHub CLI, you log in once per account, switch the active session in seconds, keep author identity local to each repo, and clone confidently from the right profile. Fewer moving parts, fewer surprises — and the setup survives across machines.


Useful docs: GitHub CLI authentication · Set up Git credential helper

Thanks for reading!

I hope you found this article helpful, interesting, or useful! If you have questions, or just want to chat about web development, I'd love to hear from you.

Want to see what I'm building? Check out my projects or connect with me:

Published on August 13, 2025