Problem
When trying to add a second GitHub personal access token (PAT) in Settings | Version Control | GitHub, the IDE rejects the new token with a message indicating that the GitHub account is already added — even when the new PAT is scoped to a different resource (for example, a team or organization repository) than the existing one.
This affects fine-grained PATs in particular, because GitHub fine-grained tokens are scoped per resource owner: a single GitHub user can hold multiple fine-grained PATs, each granting access to a different set of repositories or organizations.
Cause
The IntelliJ-based IDE associates a single credential (PAT or OAuth token) with a single GitHub user account. When a PAT is added, the IDE queries GitHub to determine which user owns it. If a credential is already configured for that user, the IDE refuses to add a second one — regardless of the scopes or resources granted by the new token.
Tracking issue: IJPL-179595 — Better support for GitHub fine-grained personal access tokens.
Resolution
Option 1: Use a single token with broader scope
If both repositories belong to the same GitHub user (including memberships in organizations the user can access), create a single token that grants access to all required repositories and organizations:
- A classic personal access token is not scoped per resource and can act as a single credential for both personal repositories and accessible organization repositories.
- A fine-grained PAT can also be used, provided its Resource owner and selected repositories cover all targets.
Add this single token in Settings | Version Control | GitHub.
Option 2: Use the Git credential helper for per-repository credentials
If a single token cannot grant the required access (for example, the organization restricts classic PATs and requires a separate fine-grained PAT scoped to the organization), bypass the IDE's GitHub account integration and let Git handle credentials per repository URL through the OS credential manager:
-
Open Settings (Ctrl+Alt+S on Windows/Linux, ⌘, on macOS) and navigate to Version Control | Git.
-
Enable Use credential helper.
-
In a terminal, configure Git to key stored credentials by full repository URL:
git config --global credential.https://github.com/.useHttpPath true
After this configuration, Git prompts for credentials separately for each repository on first access and stores the per-repository token in the OS credential manager (Keychain on macOS, Credential Manager on Windows, libsecret-compatible store on Linux). Different tokens can then be supplied for different repositories owned by the same GitHub user.
Note: Features that rely on the in-IDE GitHub account (such as the Pull Requests tool window or Share Project on GitHub) still use the single account configured in Settings | Version Control | GitHub. The credential helper workaround applies to standard Git operations (clone, fetch, push, pull).
Comments
0 comments
Please sign in to leave a comment.