Describe the feature or problem you'd like to solve
When multiple accounts are authenticated via gh auth login, the only way to use a specific account is to switch globally with gh auth switch. This is cumbersome when you frequently need to alternate between accounts (e.g., a personal account and an Enterprise Managed User) within the same terminal session.
Current workflow:
gh auth switch --user personal-account
gh issue create --repo myorg/repo ...
gh auth switch --user work-emu-account # don't forget to switch back!
This is error-prone — it's easy to forget to switch back, causing subsequent commands to run as the wrong user.
Proposed solution
Add a global --user flag available on all gh commands that overrides the active account for that single invocation:
gh issue create --repo myorg/repo --user personal-account ...
gh pr list --repo corp/repo --user work-account
This would be especially useful for:
- Enterprise Managed Users who need to interact with both EMU-org repos and personal repos
- CI scripts that need deterministic account selection without global state mutation
- Shell aliases/functions that target specific accounts
How will it benefit CLI and its users?
- Eliminates the error-prone
switch → command → switch back pattern
- Enables concurrent multi-account usage in scripts without race conditions
- No global state mutation — pure, predictable command behavior
Additional context
Related to #326 (multiple account credentials). This proposal is a narrower, more immediately actionable enhancement that works with the existing gh auth switch infrastructure — it just needs a way to override the active account per-invocation rather than only globally.
The GH_TOKEN env var partially addresses this but requires managing raw PATs. A --user flag would work with the credentials already stored by gh auth login.
Describe the feature or problem you'd like to solve
When multiple accounts are authenticated via
gh auth login, the only way to use a specific account is to switch globally withgh auth switch. This is cumbersome when you frequently need to alternate between accounts (e.g., a personal account and an Enterprise Managed User) within the same terminal session.Current workflow:
This is error-prone — it's easy to forget to switch back, causing subsequent commands to run as the wrong user.
Proposed solution
Add a global
--userflag available on allghcommands that overrides the active account for that single invocation:This would be especially useful for:
How will it benefit CLI and its users?
switch → command → switch backpatternAdditional context
Related to #326 (multiple account credentials). This proposal is a narrower, more immediately actionable enhancement that works with the existing
gh auth switchinfrastructure — it just needs a way to override the active account per-invocation rather than only globally.The
GH_TOKENenv var partially addresses this but requires managing raw PATs. A--userflag would work with the credentials already stored bygh auth login.