Claude Code With Multiple GitHub Accounts

Claude Code pushes and opens PRs as whichever GitHub account git and gh use in that folder. How to check it and give each project the right account.

TCtThe Clawdrobe team
· 8 min read
Clawdrobe cover art titled "Claude Code With Multiple GitHub Accounts" with four account tiles

Claude Code has no GitHub login of its own. When it pushes, git uses your SSH key or credential helper; when it opens a pull request, it runs gh, which uses the GitHub CLI's active account. So to keep a work and a personal GitHub account apart, you set the account per folder in git and gh, not in Claude. Cloud sessions are the exception: they use the GitHub connection stored with your Claude account.

This guide shows how to check which GitHub account a session will use, three ways to pick the right one per project, and what changes when you also have more than one Claude account.

Where Claude Code gets its GitHub access#

A local Claude Code session touches GitHub in two ways, and each has its own login:

  • git push and git pull use the remote's address. A [email protected]:… remote uses an SSH key from ~/.ssh. An https://github.com/… remote asks a credential helper, usually the macOS Keychain (osxkeychain) or gh itself if you ran gh auth setup-git.
  • gh pr create, gh issue list and the rest use the account gh has marked as active, or a token in GH_TOKEN if one is set.

The two can disagree. It's common to push with your personal SSH key and then watch gh open the pull request as your work account, or the other way round. Neither one knows which Claude account you're signed in to.

Step 1: check which account a session will use#

Open a terminal in the repository and run:

git remote -v
ssh -T [email protected]
git config --get credential.helper
gh auth status

git remote -v tells you whether pushes go over SSH or HTTPS. For SSH, ssh -T [email protected] answers "Hi username!" with the account your key belongs to. If you use Option 2 below, test the key git really uses: $(git config core.sshCommand) -T [email protected], or ssh -T git@github-work for a host alias. For HTTPS, the credential helper line tells you where the password comes from. gh auth status lists every account gh knows, marks the active one, and says so when a GH_TOKEN variable is overriding them all.

Run these in the same place Claude Code runs. A variable set only inside Claude Code's settings won't show in a plain Terminal, so you can also ask Claude to run gh auth status in the session.

Step 2: pick a fix#

Option 1: switch gh between accounts#

Since version 2.40, gh can hold several accounts for github.com. Log in once per account, then switch:

gh auth login          # once for each account
gh auth switch --user your-work-username
gh auth status

This is the quickest fix and fine if you work on one side at a time. The catch is that the switch applies to every terminal at once. If one Claude Code session is working on a client repository and another on your own project, switching for one breaks the other. It also only covers gh and HTTPS pushes through gh; an SSH remote keeps using whatever key SSH offers.

Option 2: one SSH key per account, chosen by folder#

For pushes, give each GitHub account its own SSH key and let git pick it from the folder. Keep client repositories under one folder, say ~/work, and add this to ~/.gitconfig:

[includeIf "gitdir:~/work/"]
    path = ~/.gitconfig-work

Then in ~/.gitconfig-work:

[core]
    sshCommand = ssh -i ~/.ssh/id_ed25519_work -o IdentitiesOnly=yes

Every repository under ~/work now pushes with the work key, and everything else with your default key. IdentitiesOnly=yes matters: without it, SSH offers the keys loaded in your agent first, and GitHub accepts the first one it recognizes, which may be the wrong account. The same included file is a good place for the work user.email, which keeps the commit author right too.

If you'd rather not sort repositories by folder, an alias in ~/.ssh/config does the same per remote:

Host github-work
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_ed25519_work
    IdentitiesOnly yes

and the remote becomes git@github-work:your-org/repo.git.

Option 3: a separate gh login per project#

gh keeps its login list in ~/.config/gh unless GH_CONFIG_DIR points somewhere else. Make a second folder for the work account and log in there once:

GH_CONFIG_DIR=~/.config/gh-work gh auth login --insecure-storage

--insecure-storage keeps this login's token in ~/.config/gh-work/hosts.yml instead of the Keychain. That matters: on a Mac, gh keeps the active token in one Keychain item for github.com that every config folder shares, so a normal login here would replace your default account's token. Afterwards, run plain gh auth status in Terminal and check your default account didn't change.

Now tell Claude Code to use it in that project. Claude Code's settings take an env block, and .claude/settings.local.json is your personal settings file for one project (Claude Code keeps it out of git when it creates the file; if you create it by hand, add it to .gitignore):

{
  "env": {
    "GH_CONFIG_DIR": "/Users/you/.config/gh-work"
  }
}

Use the full path: Claude Code copies these values as written, so a ~ stays a literal ~. Once you've trusted the folder, every gh command Claude runs in that repository uses the work login, while your own Terminal and other projects keep the default one. Claude Desktop's Code tab reads the same file for local sessions. If you prefer direnv, an export GH_CONFIG_DIR=… in the folder's .envrc works for sessions you start from Terminal in that folder.

Avoid GH_TOKEN in these files. It's plain text on disk like hosts.yml above, but it also beats every login gh auth status would show you, in every repository where it's set.

Cloud sessions and /web-setup#

Claude Code sessions in the cloud don't use your Mac's gh or SSH keys. Per Anthropic's cloud docs (as of November 2026), they reach GitHub either through the Claude GitHub App you authorize in the browser, or through /web-setup, which reads the token gh auth token prints and stores it with your Claude account.

That makes the order of steps matter. /web-setup sends the token of whichever gh account is active at that moment (or the one GH_CONFIG_DIR points to in that session), and it replaces an earlier GitHub connection on that Claude account. With a work and a personal Claude account, run gh auth switch to the matching GitHub account before you run /web-setup in each. To undo a wrong one, disconnect GitHub at claude.ai/customize/connectors and run it again. On Team and Enterprise plans, /web-setup only works after an Owner turns on Quick setup.

When you also have more than one Claude account#

The GitHub fixes above don't care which Claude account you're using. Matching the two is up to you: keep the client's repositories in the client's folder, and use the same folder rule for the Claude account, the GitHub account and the commit email.

Clawdrobe is a Mac app that runs several Claude accounts side by side, each with its own Claude Desktop app and its own Claude Code sign-in. It doesn't log in to GitHub or touch your SSH keys, but it covers the Claude half of the folder rule:

  • Each added account gets a claude-<name> command in Terminal, and its Tools → Folders (plus one hook line in ~/.zshrc) make plain claude in a client's folder run as that account.
  • Commit As in the account's Tools gives the commits from those sessions the account's name and email.
  • An optional status line shows in every Claude Code session which Claude account it runs as.

Pair it with Option 2 or 3 in the same folders and a client's repository gets the client's Claude account, GitHub account and email together. Clawdrobe is free for two accounts with every feature, and Clawdrobe Pro is a one-time $10 for more. It needs macOS 26 or later and isn't affiliated with Anthropic.

Pitfalls#

  • The Keychain remembers one github.com password. With HTTPS remotes and osxkeychain, the first login wins for every repository. Switch those remotes to SSH, or set git config --global credential.https://github.com.useHttpPath true so the Keychain stores one login per repository path.
  • gh auth switch in the middle of a session. A running session picks up the switch on its next gh call. If two sessions need different accounts, use Option 3 instead.
  • A forgotten GH_TOKEN. An old export in ~/.zshrc overrides every login. gh auth status names it; remove it there.
  • Pushes work, pull requests fail. That usually means git and gh are on different accounts and the gh one can't see the repository. Run the four checks from Step 1 and line them up.

Quick answers#

Can Claude Code log in to GitHub itself? No. Locally it uses git's and gh's logins. Only cloud sessions have a GitHub connection on the Claude side.

Does switching Claude accounts switch GitHub accounts? No. They are separate logins; match them by folder.

What's the simplest setup that doesn't break parallel sessions? An SSH key per account picked by includeIf for pushes, plus a separate gh login (GH_CONFIG_DIR, logged in with --insecure-storage) set in the project's .claude/settings.local.json.

More from the blog

Guide

Claude Code Committing With the Wrong Git Email?

Clawdrobe8 min read

Claude Code commits with whatever git is set to in that folder, not your Claude account's email. How to check it, fix it per folder, and repair past commits.

Guide

How to Run Claude Code Sessions in Parallel

Clawdrobe8 min read

Run several Claude Code sessions at once without edits colliding: one git worktree per session, agent view for background tasks, and what it does to limits.

Explainer

Claude Team Plan: Price, Limits and Team vs Pro

Clawdrobe8 min read

Claude Team costs $25 a seat a month ($20 billed yearly) for 2 to 150 people. What Standard and Premium seats get, how limits work, and Team vs Pro.

Every Claude account, side by side

Clawdrobe is free for two accounts. macOS 26 or later · Apple silicon and Intel.