You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Offer to fork when "Push Commits" targets a read-only remote in Create PR - #9136
Creating a PR on a repo you can't push to (for example, a quick fix in Codespaces) fails when the branch already tracks the read-only remote and has unpushed commits. The Publish Branch path already offers to fork; the Push Commits path pushed straight to the tracked remote. That push either failed, or VS Code's built-in GitHub push-error handling forked behind our back, so the PR head pointed at the original repo instead of the fork.
Changes (CreatePullRequestViewProvider)
Push through publishBranch: a new pushCommits helper sends Push Commits through FolderRepositoryManager.publishBranch. That gives this path the same permission check, fork prompt, and push-error modals as Publish Branch. If the tracked remote isn't a known GitHub repository, it falls back to a plain push as before.
Fork becomes the head: when the commits land in a fork, compareOwner/compareRepositoryName are reassigned to the fork. headRepo then resolves to the fork, the head becomes <fork-owner>:<branch>, and the PR still targets the original repo.
Clean cancel: declining the fork, hitting a rate limit, or a rejected push cancels creation without creating a PR.
Behaviour change for users with write access:Push Commits now pushes with -u and shows the modal warnings from Publish Branch on failure.
Model not updated:CreatePullRequestDataModel.compareOwner isn't changed after a fork, which matches the existing publish path. So if creation fails after a fork, a retry from the same view would use the original repo as the head.
Not covered: creating a patch-n branch automatically when compare == base, as GitHub's web editor does. The view still disables Create in that case.
Tests
New Create pull request with unpushed commits suite in createPRViewProvider.test.ts covers three cases:
Write access: pushes to origin with -u; head is github:D4.
Read access, fork accepted: forks, pushes to the fork, and creates the PR with head contributor:D4 against github/test.
…ing a PR
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
CopilotAI
changed the title
[WIP] Add auto-fork feature for branch creation
Offer to fork when "Push Commits" targets a read-only remote in Create PR
Oct 29, 2026
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Fork publishing mishandles configured push destinations and retry state, which can block valid pushes, make retries fail, or create pull requests from the wrong repository.
Extends the Create PR flow to offer a fork when unpushed commits target a read-only remote, addressing the Codespaces contribution workflow described in #2998.
Changes:
Routes Push Commits through the existing publish flow for permission checks, fork prompts, and push-error handling.
Uses the fork as the PR head and updates the compare-owner model after a successful fork push.
Adds tests for writable remotes, accepted forks, and declined forks.
File
Description
src/test/github/createPRViewProvider.test.ts
Adds coverage for pushing unpushed commits and fork decisions.
src/github/createPRViewProvider.ts
Adds fork-aware pushing, cancellation handling, and fork head selection.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Push-destination validation can send commits to an unrelated repository, while URL-alias handling and stale compare state can leave the PR pointing at the wrong head.
Persist the head repository for differently named forks
src/github/createPRViewProvider.ts:1691
For a writable fork with a different name, such as contributor/test-fork, this guard skips updating both the model and the webview. If pushing succeeds but PR creation fails, a retry with no unpushed commits skips pushCommits() and uses the stale original repository as the head, potentially omitting the pushed changes. Persist both the actual compare owner and repository independently of the base repository name.
Resolve push URL aliases before validating the destination
src/github/folderRepositoryManager.ts:3335
With a GitHub fetch URL and an aliased push URL such as gh:contributor/test, this parses gh as the host instead of applying Git's url.*.insteadOf substitution. The server check fails, so pushCommits() falls back to a plain push and leaves the PR head on the original repository even though the commits land in the fork. Resolve the alias before parsing and checking the push destination, as parseRepositoryRemotesAsync() does.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Remote validation can accept an unrelated push target or reject a valid fork with an outdated local URL, risking misdirected pushes or failed fork operations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Creating a PR on a repo you can't push to (for example, a quick fix in Codespaces) fails when the branch already tracks the read-only remote and has unpushed commits. The Publish Branch path already offers to fork; the Push Commits path pushed straight to the tracked remote. That push either failed, or VS Code's built-in GitHub push-error handling forked behind our back, so the PR head pointed at the original repo instead of the fork.
Changes (
CreatePullRequestViewProvider)publishBranch: a newpushCommitshelper sends Push Commits throughFolderRepositoryManager.publishBranch. That gives this path the same permission check, fork prompt, and push-error modals as Publish Branch. If the tracked remote isn't a known GitHub repository, it falls back to a plainpushas before.compareOwner/compareRepositoryNameare reassigned to the fork.headRepothen resolves to the fork, the head becomes<fork-owner>:<branch>, and the PR still targets the original repo.Review notes
-uand shows the modal warnings from Publish Branch on failure.CreatePullRequestDataModel.compareOwnerisn't changed after a fork, which matches the existing publish path. So if creation fails after a fork, a retry from the same view would use the original repo as the head.patch-nbranch automatically when compare == base, as GitHub's web editor does. The view still disables Create in that case.Tests
New
Create pull request with unpushed commitssuite increatePRViewProvider.test.tscovers three cases:originwith-u; head isgithub:D4.contributor:D4againstgithub/test.