Replies: 3 comments
-
|
Right now we don't support multiple user accounts. #326 |
Beta Was this translation helpful? Give feedback.
-
|
For people coming here in the future: |
Beta Was this translation helpful? Give feedback.
-
|
Multiple gh-cli accounts on one machine is now supported with Current state (gh 2.x): # Add a second account
gh auth login --hostname github.com
# List accounts
gh auth status
# Switch active account
gh auth switch --user seconduser
# Or switch by hostname (for GitHub Enterprise)
gh auth switch --hostname enterprise.github.comThe friction: the active account is global, not per-directory or per-repo. This means if you have work and personal repos in adjacent directories, you have to manually switch before each gh command. Workaround for directory-based switching: # In your work directory's .envrc (with direnv)
export GH_TOKEN=$(cat ~/.config/gh/work-token)
# Or in a per-repo shell alias
alias ghp='GH_TOKEN=$(cat ~/.config/gh/personal-token) gh'
alias ghw='GH_TOKEN=$(cat ~/.config/gh/work-token) gh'The For AI agents and automation: when building multi-agent workflows that interact with GitHub, per-token isolation is important β each agent should use a scoped token (fine-grained personal access token) with only the repos and permissions it needs, rather than shared global auth. This follows the principle of least privilege and makes it easier to audit which agent took which action. Is the use case switching between GitHub.com accounts, or between GitHub.com and GitHub Enterprise? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I was thinking since this is not a feature maybe I can find a way to submit a pull request but wanted to get advice or thoughts about this idea.
I would like to be able to use gh auth to login to GitHub with multiple accounts.
Ex: gh auth login personalaccount --profile=1
Ex: gh auth login workaccount --profile=2
The hopes would be to push, pull, etc within one repo dir will follow those commands.
Not sure if a hidden file or a variable in the .git dirs config would help determine the profile and token to use.
Anyone else think this would be helpful and that I should consider building this... Or have any insight on the difficulties?
Beta Was this translation helpful? Give feedback.
All reactions