Switch between GitHub Copilot CLI accounts
To switch GitHub Copilot CLI accounts, sign in to each with copilot login, save them with yoink save gh-work --tool copilot, then run yoink use gh-work. Copilot keeps a token per GitHub user, so yoink only rewrites last_logged_in_user in ~/.copilot/config.json. It swaps no credential files.
On this page
The short answer
yoink add
yoink save gh-work --tool copilot
yoink save gh-personal --tool copilot
yoink use gh-work
yoink current --tool copilotRun yoink save once while each account is the active one, or let yoink add (pick GitHub Copilot) run the sign-in for you. After that, yoink use <name> moves Copilot to that account:
✔ Switched to gh-work (octo-work)
Restart the Copilot CLI to pick up the new login.How Copilot stores several users
Copilot CLI's login home is $COPILOT_HOME when that variable is set, otherwise ~/.copilot. Its config.json already knows about more than one GitHub account. yoink reads two keys from it:
| Key | Holds |
|---|---|
logged_in_users | every account that has signed in on this machine, each as { "host", "login" } |
last_logged_in_user | the one account Copilot uses now, in the same shape |
Because Copilot keeps the tokens for each signed-in user itself, a yoink Copilot profile is unusually small: it stores the host and login of one account and nothing else. There is no Copilot token in ~/.config/yoink/subscriptions.json. The name shown is the GitHub login, and for a host other than https://github.com, such as a GitHub Enterprise server, it becomes login@host (for example octo@ghe.example.com).
Add another GitHub login
copilot login adds an account without signing the others out, so adding one is straightforward. Through yoink, run yoink add and choose GitHub Copilot. yoink saves the account that is active now as a profile (if none holds it yet), then runs copilot login. Finish the GitHub device login in your browser, come back to the terminal, and yoink captures the new account and asks for a profile name.
Prefer to do it yourself? Save the current account first with yoink save gh-work --tool copilot, run copilot login as the second user, then yoink save gh-personal --tool copilot. Both accounts stay in logged_in_users, so neither sign-in is lost.
What a switch changes (one key)
yoink use gh-personal reads config.json, finds the matching entry in logged_in_users, and writes it into last_logged_in_user. Every other key in the file is kept as it was. The file is written atomically with owner-only permissions, as formatted JSON.
Hosts are compared without case or a trailing slash, and logins without case, so https://GitHub.com/ and https://github.com count as the same server. If the account in the profile is not in logged_in_users any more, yoink refuses with a message such as:
✖ octo@ghe.example.com is not logged in to GitHub Copilot on this machine. Run `copilot login` as that user first.yoink also refuses, with a hint to run copilot login, when config.json is missing. If Copilot is running (a process named copilot), yoink asks before switching, and a script must pass --force. The full sequence is in What a switch does.
Environment variables that override the login
Copilot prefers a token from the environment over the stored login. After every switch, yoink checks three variables, COPILOT_GITHUB_TOKEN, GH_TOKEN and GITHUB_TOKEN, and prints one warning naming every one of them that is set and non-empty:
! GH_TOKEN is set and overrides the stored GitHub Copilot login. Unset it for the switch to take effect.The switch itself still happens. Unset the named variables in the shell where you start Copilot, or the account in last_logged_in_user will not be the one in use.
FAQ
Does yoink copy my GitHub token anywhere?
No. A Copilot profile holds only the host and login of an account. The token stays wherever Copilot itself keeps it, and yoink never copies it into a profile.
Can I switch between github.com and a GitHub Enterprise account?
Yes, as long as both have signed in with copilot login on this machine. yoink matches on host and login together, so the two show up as separate profiles and switch like any other pair.
Does a Copilot switch affect Claude Code, Codex or the gh CLI?
It changes only last_logged_in_user in Copilot's config.json. Claude Code and the other subscription tools keep their logins. yoink does not touch the gh CLI's own configuration.
Related
- Subscriptions
Save and switch ChatGPT (Codex), Kimi Code, Gemini and GitHub Copilot logins with yoink, each inside its own tool, with the live login re-saved first.
- Switch between Gemini CLI accounts
Save more than one Google login for Gemini CLI and switch between them. yoink swaps oauth_creds.json and google_accounts.json and refuses encrypted storage.
- How it works
How yoink switches Claude Code accounts: the Keychain entry or .credentials.json, the oauthAccount block in ~/.claude.json, and the re-snapshot step first.
- Switch between Claude Code accounts
Keep a work and a personal Claude Code account and switch in one command. yoink swaps the Keychain entry or .credentials.json and the oauthAccount block.
- Switch between Codex (ChatGPT) accounts
Save several ChatGPT logins for Codex and switch between them. yoink swaps auth.json or the Codex Auth Keychain entry and re-saves the live login first.