Repository navigation
Associate repositories with a specific account - #23020
Conversation
GitHub Desktop now allows multiple signed-in accounts per endpoint, so repositories carry an explicit account assignment (endpoint + login) which is used for all API and HTTPS Git credentials. - Add a nullable login to the repository model with a one-time migration assigning existing repositories to their endpoint's account - Choose the account in Repository Settings; prompt on explicit operations when unassigned or when the assigned account is signed out, with targeted reauthentication for the missing login - Ask whether to keep or clear assignments on explicit sign-out while preserving them when accounts are removed automatically - Resolve trampoline credentials from the repository at the operation's path using a cached copy of the repositories store, with a token-free fallbackAccount for clones and tutorial pushes - Route CI, pull request, issue, mention, and notification API requests through the repository's account - Probe account access when cloning or adding repositories - Scope GitHub repository metadata per account to isolate permissions, protected branches, and cached pull requests - Clear the assignment when a remote moves to another endpoint Co-authored-by: Copilot App <[email protected]>
Brings in short-lived token support (#22917, #22937, #22938, #22939) and adapts it to multiple accounts per endpoint: - Credential sessions are keyed per account (endpoint + login) instead of per endpoint, so renewal, invalidation and storage writes are isolated. - AccountsStore lookups, retirement and refresh match the exact account. - The invalidated token dialog names the signed-out login and offers a targeted sign-in for that account. Co-authored-by: Copilot App <[email protected]>
Fetch, pull and push no longer require an account before running Git. The credential helper already prompts for an account when Git requests HTTPS credentials during a user-initiated operation, so SSH remotes and public HTTPS repositories work without an account, and background fetches run again for unassigned repositories or signed-out assigned accounts. Co-authored-by: Copilot App <[email protected]>
When an unassigned repository needs an account and no account is signed in for its endpoint, show the regular sign-in prompt for that endpoint instead of an account choice with nothing to choose from. The signed-in account is assigned to the repository. Co-authored-by: Copilot App <[email protected]>
The pickers looked up the selected account by endpoint only, so choosing a second account on the same host silently used the first. Accounts are now matched by endpoint and login, and a clone from the GitHub tabs is pinned to the chosen account with no fallback to other accounts on the endpoint. Co-authored-by: Copilot App <[email protected]>
A repository whose remote was removed keeps its account assignment. Opening Publish for it now starts on that account's tab with the account selected. Co-authored-by: Copilot App <[email protected]>
Repositories on the GitHub tabs of the clone dialog are listed by the selected account, so probing that account for access is redundant. Worse, a transient probe failure left the cloned repository unassigned. The selected account is now assigned directly and the repository's metadata is fetched on the next refresh. Co-authored-by: Copilot App <[email protected]>
The account picker and the remote URL each rendered their own dialog content, and each received the dialog's minimum height, leaving large gaps. Both now share one content area, with the account below the remote and its help text styled as a description. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
The credential helper normalized the requested URL to an API endpoint before matching the repository's assigned account or the fallback account, which discarded the scheme and port. A plain HTTP request to the same host would receive the account's token. Require the request's origin to match the account's web origin, as before repository assignments. Co-authored-by: Copilot App <[email protected]>
A locked or failing keychain at startup made accounts drop out of AccountsStore.getAll(), so the one-time migration permanently wrote null for their repositories. Migrate from the endpoint and login of every saved account instead. Co-authored-by: Copilot App <[email protected]>
Adding a local repository that no account can access matched its remote against the first signed-in account on the host, leaving an orphaned GitHub repository record scoped to that login. Use an anonymous match instead, shared with repositoryWithRefreshedGitHubRepository. Co-authored-by: Copilot App <[email protected]>
Saving a new account and remote URL together passed the stale repository to setRemoteURL, so the GitHub association refresh bailed because the login had changed. Return the updated repository from updateRepositoryAccount and use it for the remote update. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Adding, cloning and publishing set the GitHub repository and then the account in two steps. The first step scoped the record to the new repository's empty login, leaving an orphaned copy behind. Let setGitHubRepository assign the login in the same transaction. Co-authored-by: Copilot App <[email protected]>
Repository state and GitStores are keyed by the repository hash, which changes when the account is reassigned and again when the new account's GitHub metadata is refreshed. Both reset the in-progress commit message. Carry the repository state and the GitStore draft over to the new identity in those two places. Co-authored-by: Copilot App <[email protected]>
Sessions were keyed by endpoint, so a second account on the same endpoint shared the first account's websocket, and signing out either account took the shared session offline for both. Co-authored-by: Copilot App <[email protected]>
Drop getAccountForEndpoint, upsertGitHubRepositoryLight, promptForGitHubSignIn and its SignIn popup fields, and redundant dynamic imports in AppStore. Co-authored-by: Copilot App <[email protected]>
Resolve conflicts with refreshable OAuth tokens, credential leases and session-bound account snapshots: - CredentialSessions keys sessions by account (endpoint and login) while keeping development's session binding, leases and expiry overrides. - The credential trampoline leases a fresh token for the repository's assigned (or fallback) account. It only sends credentials when the request's origin (scheme, host and port) exactly matches the repository's endpoint, rather than comparing an https API URL rebuilt from the request. The two are equivalent for real accounts, whose endpoints are always https, and the exact match also works with the test servers development's credential tests use. - Sign-in now saves the account before completing, so reauthentication checks the expected login before saving and AppStore no longer tracks account persistence. - The token expiration test dialog selects accounts by account key. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Credential origin isolation and account-selection behavior have unresolved correctness and security issues.
5 open findings
Preserve Enterprise Server ports in allowed origin checks · New Distinguish probe failures from inaccessible repositories · New Allow URL-tab clones to probe alternate accounts after 404s · New Clear organization selection when switching GitHub accounts · New Re-probe newly signed-in accounts before accepting them · New
What changed in this PR
Adds explicit repository account assignments to support multiple accounts on the same GitHub endpoint.
Changes:
- Scopes credentials and repository metadata by account.
- Adds account selection and targeted sign-in/sign-out flows.
- Updates account-aware consumers, regression tests, and documentation.
| File | Description |
|---|---|
| docs/technical/oauth.md | Documents assignments and authentication behavior. |
| app/test/unit/ui/welcome-and-sign-in-wrappers-test.tsx | Tests targeted sign-in and dialog closure. |
| app/test/unit/ui/test-token-expiration-dialog-test.tsx | Uses account-specific selection keys. |
| app/test/unit/ui/rulesets-and-publish-surfaces-test.tsx | Updates layout assertions. |
| app/test/unit/ui/repository-settings-account-test.tsx | Tests assignment editing and persistence. |
| app/test/unit/ui/pull-request-quick-view-test.tsx | Tests account context propagation. |
| app/test/unit/ui/preferences-accounts-test.tsx | Tests multiple-account preferences. |
| app/test/unit/ui/notification-checks-account-test.tsx | Tests account-aware log enrichment. |
| app/test/unit/ui/multi-account-pickers-test.tsx | Tests clone and publish account selection. |
| app/test/unit/ui/issues-autocompletion-provider-test.tsx | Supplies local repository context. |
| app/test/unit/ui/invalidated-token-test.tsx | Tests account-specific recovery. |
| app/test/unit/ui/ci-status-test.tsx | Tests subscription changes after reassignment. |
| app/test/unit/tutorial-repository-accounts-test.ts | Tests tutorial assignments and metadata. |
| app/test/unit/stores/updates/update-remote-url-test.ts | Narrows repository metadata before use. |
| app/test/unit/stores/app-store-token-refresh-stats-test.ts | Supplies repository store dependency. |
| app/test/unit/stores/app-store-indicators-test.ts | Supplies repository store dependency. |
| app/test/unit/repository-matching-test.ts | Tests account probing and selection. |
| app/test/unit/repository-account-test.ts | Tests assignment resolution and migration. |
| app/test/unit/repositories-database-test.ts | Tests account-scoped metadata migration. |
| app/test/unit/refresh-token-consumers-test.ts | Tests repository-aware credential renewal. |
| app/test/unit/oauth-authentication-test.ts | Tests targeted identity verification. |
| app/test/unit/notifications-store-test.ts | Updates assigned-account fixtures. |
| app/test/unit/git/refreshable-credentials-test.ts | Supplies assigned repository context. |
| app/test/unit/git/clone-fallback-account-test.ts | Tests fallback identity forwarding. |
| app/test/unit/credential-sessions-test.ts | Tests independent account sessions. |
| app/test/unit/cloning-repositories-accounts-test.ts | Tests clone assignment handling. |
| app/test/unit/api-test.ts | Tests targeted OAuth parameters. |
| app/test/unit/alive-store-test.ts | Tests per-account notification sessions. |
| app/test/unit/accounts-store-test.ts | Tests multiple accounts and persisted identities. |
| app/test/unit/account-token-lifecycle-test.ts | Updates multi-account lifecycle expectations. |
| app/styles/ui/dialogs/_repository-settings.scss | Styles account assignment controls. |
| app/src/ui/toolbar/branch-dropdown.tsx | Passes local account context to checks. |
| app/src/ui/test-notifications/test-notifications.tsx | Supplies local repository context. |
| app/src/ui/sign-in/sign-in.tsx | Supports targeted sign-in and safer closure. |
| app/src/ui/repository-settings/repository-settings.tsx | Adds account assignment editing. |
| app/src/ui/repository-settings/remote.tsx | Moves content wrapping to parent. |
| app/src/ui/repository-settings/no-remote.tsx | Moves content wrapping to parent. |
| app/src/ui/repository-account/repository-account-dialog.tsx | Adds account selection and reauthentication. |
| app/src/ui/repository-account/confirm-account-sign-out.tsx | Adds assignment-aware sign-out confirmation. |
| app/src/ui/pull-request-quick-view.tsx | Forwards local account context. |
| app/src/ui/publish-repository/publish.tsx | Supports account selection and preselection. |
| app/src/ui/preferences/test-token-expiration-dialog.tsx | Selects accounts by identity key. |
| app/src/ui/preferences/accounts.tsx | Displays multiple accounts per endpoint. |
| app/src/ui/notifications/pull-request-checks-failed.tsx | Uses assigned accounts and discards stale enrichment. |
| app/src/ui/invalidated-token/invalidated-token.tsx | Offers account-specific sign-in recovery. |
| app/src/ui/index.tsx | Wires repository-aware stores and credentials. |
| app/src/ui/dispatcher/dispatcher.ts | Routes account-aware operations. |
| app/src/ui/clone-repository/clone-repository.tsx | Forwards the selected clone identity. |
| app/src/ui/check-runs/ci-check-run-rerun-dialog.tsx | Supplies account context for reruns. |
| app/src/ui/check-runs/ci-check-run-popover.tsx | Refreshes subscriptions when context changes. |
| app/src/ui/branches/pull-request-list.tsx | Passes local repository context. |
| app/src/ui/branches/pull-request-list-item.tsx | Forwards account context to status. |
| app/src/ui/branches/pull-request-badge.tsx | Forwards account context to status. |
| app/src/ui/branches/ci-status.tsx | Resubscribes after account changes. |
| app/src/ui/branches/branches-container.tsx | Supplies quick-view account context. |
| app/src/ui/autocompletion/issues-autocompletion-provider.tsx | Refreshes issues using local context. |
| app/src/ui/autocompletion/build-autocompletion-providers.ts | Resolves the assigned account. |
| app/src/ui/app.tsx | Renders account dialogs and passes context. |
| app/src/models/retry-actions.ts | Retains clone account options for retries. |
| app/src/models/repository.ts | Adds login to repository identity. |
| app/src/models/popup.ts | Defines account-aware popup payloads. |
| app/src/models/clone-options.ts | Defines token-free clone identity options. |
| app/src/models/account.ts | Adds account identity helpers. |
| app/src/lib/trampoline/trampoline-ui-helper.ts | Routes repository account prompts. |
| app/src/lib/trampoline/trampoline-environment.ts | Tracks operation fallback identities. |
| app/src/lib/trampoline/trampoline-credential-helper.ts | Resolves credentials from repository assignments. |
| app/src/lib/trampoline/find-account.ts | Narrows the required store interface. |
| app/src/lib/stores/sign-in-store.ts | Verifies targeted OAuth identities. |
| app/src/lib/stores/repository-state-cache.ts | Exposes cached-state presence. |
| app/src/lib/stores/pull-request-store.ts | Scopes metadata upserts by account. |
| app/src/lib/stores/notifications-store.ts | Uses assignments and rejects stale work. |
| app/src/lib/stores/notifications-debug-store.ts | Scopes notification caches by account. |
| app/src/lib/stores/helpers/create-tutorial-repository.ts | Supplies a fallback push identity. |
| app/src/lib/stores/helpers/background-fetcher.ts | Uses the assigned account. |
| app/src/lib/stores/git-store-cache.ts | Exposes cached-store presence. |
| app/src/lib/stores/cloning-repositories-store.ts | Tracks selected clone assignments. |
| app/src/lib/stores/alive-store.ts | Keys notification sessions by account. |
| app/src/lib/stores/accounts-store.ts | Retains multiple accounts and saved identities. |
| app/src/lib/repository-matching.ts | Probes access and selects accounts. |
| app/src/lib/git/core.ts | Forwards fallback identity to the trampoline. |
| app/src/lib/git/clone.ts | Passes fallback identity into Git execution. |
| app/src/lib/get-account-for-repository.ts | Resolves endpoint and assigned login. |
| app/src/lib/databases/repositories-database.ts | Adds account-scoped metadata migration. |
| app/src/lib/credential-sessions.ts | Isolates credential lifecycle by account. |
| app/src/lib/api.ts | Adds targeted OAuth authorization parameters. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Check repository access with fetchRepositoryIfAccessible, which only treats a 404 as no access and throws on any other failure. Previously a timeout or server error for one account could silently assign another account, or clone a repository without credentials. Also check an account signed in from the account chooser before using it, rather than rejecting it because it wasn't among the accounts checked up front. Co-authored-by: Copilot App <[email protected]>
|
@niik probably worth updating the branch (stack) now, since there are some conflicts with |
Co-authored-by: Copilot App <[email protected]>
Remotes were matched to accounts by hostname only, so an HTTPS remote on a GitHub Enterprise Server's custom port never matched its account (and could match an account for the same host on the default port). Deriving the endpoint from an SSH remote's host also lost the web port, and kept an ssh:// port as if it were one. HTTPS remotes now match an endpoint's host including its port, SSH remotes match its hostname, and refresh resolves a remote's endpoint from the current association and signed-in accounts before deriving one. Co-authored-by: Copilot App <[email protected]>
|
All up to date again! |
…tity Publishing assigns the chosen account before pushing so Git uses its credentials, but that changes the repository's hash and left the push reading empty state (no remote), reopening the Publish dialog instead of pushing. Carry the state over and refresh the new identity before pushing. Also carry over in-memory state (such as commit message drafts) when a refresh associates or clears a repository's GitHub repository, and when signing out clears account assignments. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
sergiou87
left a comment
There was a problem hiding this comment.
Copilot found another bug and I was able to reproduce it. It's quite nasty but not sure how often users will run into this. Happy to leave this for another PR if you want!
Changing a repository's account (or its GitHub metadata) changed its hash, which was the key of the repository state and GitStore caches. Operations already running kept the previous identity, so e.g. a fetch running when the account changed cleared its in-progress flag on state nobody was looking at, leaving the repository busy. Both caches are now keyed by the repository id and path, so there's a single state and GitStore per working directory regardless of account. GitStores adopt the latest repository snapshot so later operations use the current account, and results loaded with a previous account (pull requests, branch protection) are discarded. Repository store updates are never emitted with data older than an update a caller already got back, and renaming a worktree is refused while an operation is running. Co-authored-by: Copilot App <[email protected]>
Updating a repository's missing flag, gitDir or path returned a repository derived from the caller's snapshot, which may predate an account change, and adopting it rolled the GitStore back to the previous account. They now return the persisted repository. A repository adopted before its GitStore exists is also remembered, so a store created later from an older snapshot uses it. Renaming the current worktree now also stops fetches, commits and commit message generation from starting until the rename has finished, since their state is moved to the new path. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
sergiou87
left a comment
There was a problem hiding this comment.
All good now, thanks for those fixes!!
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
The rename now runs from the main worktree (#23056). Co-authored-by: Copilot App <[email protected]>
|
EYAS MEU |
|
New folder (2).zip pottoilo |


Description
GitHub Desktop has supported one account per endpoint. This lets several accounts be signed in to the same endpoint, and makes the choice of account for each repository explicit. Every repository now stores an assigned account login, which, together with its GitHub repository's endpoint, decides which credentials are used for API calls and HTTPS Git operations.
Repositorygains a nullablelogin.accountLogin), so permissions, pull request metadata and branch protections from one identity never leak into another.createCredentialHelperTrampolineHandlernow takes the repositories store, which it mirrors the same way it already mirrors accounts.docs/technical/oauth.md.Known follow-ups
These are deferred and tracked separately:
Screenshots
TBD
Release notes
Notes: no-notes