Skip to content

Feature: per-command user selection (--user flag) #13088

Description

@cataggar

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.

Activity

  1. changed the title [-]Feature: per-command account selection (--account flag or GH_USER env var)[/-] [+]Feature: per-command user selection (--user flag)[/+] on Apr 3, 2026
  2. added a commit that references this issue on Apr 3, 2026
    d6e7e6c
  3. sergiou87 commented on Apr 6, 2026

    @sergiou87
    Contributor

    Hello! This feels like a duplicate of #12145 so I'm gonna close this one in favor of it. Happy to reopen if my assessment is wrong!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions