Repository navigation
Description
The problem
When Desktop previews a pull request for a branch that was created from the parent repository's default branch (for example git switch -c topic upstream/main), the preview is computed against the fork's own default branch. The pull request that is actually created targets the parent repository's default branch. If the fork's default branch is behind upstream, the preview lists every upstream commit as if it belonged to the pull request, reports that the branch cannot be merged automatically, and shows unrelated file changes.
Release version
3.6.10 (x64)
Operating system
Windows 11 (10.0.26300)
Steps to reproduce the behavior
- Find someone else's repo maintained actively.
- Fork it and clone the fork. Leave the fork's main behind the parent's main. (Go to your fork's homepage on GitHub to check this.)
- Create a branch from the parent's default branch.
- Make sure you are on the branch just created and make changes.
- Commit amd push.
- Preview the PR. (You will see the PR also containing all commits behind the upstream.)
- Click Create pull request. (The GitHub page open contains only the one commit created in Step 5.)
Log files
No response
Screenshots
Additional context
Root cause
desktop/app/src/lib/stores/app-store.ts
Lines 10036 to 10047 in ffeefe5
| public async _startPullRequest(repository: Repository) { | |
| const { tip, defaultBranch } = | |
| this.repositoryStateCache.get(repository).branchesState | |
| if (tip.kind !== TipState.Valid) { | |
| // Shouldn't even be able to get here if so - just a type check | |
| return | |
| } | |
| const currentBranch = tip.branch | |
| this._initializePullRequestPreview(repository, defaultBranch, currentBranch) | |
| } |
desktop/app/src/lib/stores/app-store.ts
Line 10046 in ffeefe5
| this._initializePullRequestPreview(repository, defaultBranch, currentBranch) |
desktop/app/src/lib/stores/app-store.ts
Lines 10061 to 10064 in ffeefe5
| const pullRequestCommits = await gitStore.getCommitsBetweenBranches( | |
| baseBranch, | |
| currentBranch | |
| ) |
desktop/app/src/lib/stores/app-store.ts
Lines 10073 to 10078 in ffeefe5
| getBranchMergeBaseChangedFiles( | |
| repository, | |
| baseBranch.name, | |
| currentBranch.name, | |
| commitsBetweenBranches[0] | |
| ) |
desktop/app/src/lib/stores/app-store.ts
Lines 8697 to 8736 in ffeefe5
| public async _openCreatePullRequestInBrowser( | |
| repository: Repository, | |
| compareBranch: Branch, | |
| baseBranch?: Branch | |
| ): Promise<void> { | |
| const gitHubRepository = repository.gitHubRepository | |
| if (!gitHubRepository) { | |
| return | |
| } | |
| const { parent, owner, name, htmlURL } = gitHubRepository | |
| const isForkContributingToParent = | |
| isForkedRepositoryContributingToParent(repository) | |
| const baseForkPreface = | |
| isForkContributingToParent && parent !== null | |
| ? `${parent.owner.login}:${parent.name}:` | |
| : '' | |
| const encodedBaseBranch = | |
| baseBranch !== undefined | |
| ? baseForkPreface + | |
| encodeURIComponent(baseBranch.nameWithoutRemote) + | |
| '...' | |
| : '' | |
| const compareForkPreface = isForkContributingToParent | |
| ? `${owner.login}:${name}:` | |
| : '' | |
| const encodedCompareBranch = | |
| compareForkPreface + | |
| encodeURIComponent( | |
| compareBranch.upstreamWithoutRemote ?? compareBranch.nameWithoutRemote | |
| ) | |
| const compareString = `${encodedBaseBranch}${encodedCompareBranch}` | |
| const baseURL = `${htmlURL}/pull/new/${compareString}` | |
| await this._openInBrowser(baseURL) | |
| } |
desktop/app/src/lib/stores/app-store.ts
Lines 8711 to 8714 in ffeefe5
| const baseForkPreface = | |
| isForkContributingToParent && parent !== null | |
| ? `${parent.owner.login}:${parent.name}:` | |
| : '' |
desktop/app/src/lib/stores/git-store.ts
Lines 471 to 475 in ffeefe5
| this._defaultBranch = await findDefaultBranch( | |
| this.repository, | |
| this.allBranches, | |
| this.defaultRemote?.name | |
| ) |
desktop/app/src/lib/stores/git-store.ts
Line 488 in ffeefe5
| const upstreamDefaultBranch = |
desktop/app/src/lib/stores/git-store.ts
Line 1758 in ffeefe5
| public async getCommitsBetweenBranches( |
desktop/app/src/lib/git/rev-list.ts
Lines 19 to 21 in ffeefe5
| export function revRange(from: string, to: string) { | |
| return `${from}..${to}` | |
| } |
desktop/app/src/lib/git/diff.ts
Lines 253 to 294 in ffeefe5
| export async function getBranchMergeBaseChangedFiles( | |
| repository: Repository, | |
| baseBranchName: string, | |
| comparisonBranchName: string, | |
| latestComparisonBranchCommitRef: string | |
| ): Promise<IChangesetData | null> { | |
| const baseArgs = [ | |
| 'diff', | |
| '--merge-base', | |
| '-C', | |
| '-M', | |
| '-z', | |
| '--raw', | |
| '--numstat', | |
| '--end-of-options', | |
| baseBranchName, | |
| comparisonBranchName, | |
| '--', | |
| ] | |
| const mergeBaseCommit = await getMergeBase( | |
| repository, | |
| baseBranchName, | |
| comparisonBranchName | |
| ) | |
| if (mergeBaseCommit === null) { | |
| return null | |
| } | |
| const result = await git( | |
| baseArgs, | |
| repository.path, | |
| 'getBranchMergeBaseChangedFiles' | |
| ) | |
| return parseRawLogWithNumstat( | |
| result.stdout, | |
| `${latestComparisonBranchCommitRef}`, | |
| mergeBaseCommit | |
| ) | |
| } |
Workaround
- Make sure you are on the default branch. Otherwise, switch there.
- Fetch origin.
- Create a new branch from the default named e.g.
upstream-main. - Publish the branch just created.
- Focus on the menu bar →
Click Repository → View on GitHub. - On the repo's GitHub page, next to Fork, ▼ → your remote origin repo
- Change the default branch to the one created in Step 3.
- Fetch origin.
The preview now uses upstream-main as its base, so the commit count and diffstat match what is on GitHub.
Caution
This changes the fork's default branch for everyone using that fork, and new clones will check out upstream-main instead of main. Keep upstream-main in sync with upstream/main, otherwise the preview drifts again.
Activity
[-]"Open a pull request" preview compares against the fork's default branch instead of the parent repository's default branch[/-][+]**Open a pull request** preview compares against fork's default branch instead of parent's[/+]desktop-triage commentedon Nov 4, 2026
Classification: Bug
Priority: P3
This is a reproducible bug, not a duplicate — the only prior searches turned up unrelated issues (#13533 "View fork on GitHub", #23073 commit-diff mixing, #22756 worktree uncommitted changes), none of which cover the PR-preview base-branch selection described here. The report includes version (3.6.10), OS (Windows 11), explicit numbered repro steps, and a clear expected-vs-actual contrast (GitHub creates the PR against upstream's default branch with one commit, but Desktop's preview computes the diff against the fork's own stale default branch, showing all of upstream's commits as "part of" the PR). A documented workaround exists (changing the fork's default branch), which supports a lower priority since the underlying
upstreamDefaultBranchplumbing is already present in the codebase.Information Assessment:
Recommended Labels:
bug— confirmed by tracing_startPullRequestagainstGitStore's branch state; behavior matches the reported symptom.Duplicate Check: No duplicates found. Related-but-distinct: #13533 is only about adding a "View fork on GitHub" menu entry (part of this issue's workaround steps, not the bug itself).
Suggested Next Steps: Ready for engineering review — the fix likely involves preferring
upstreamDefaultBranchoverdefaultBranchwhen starting a PR preview for a fork contributing to its parent.Initial hypothesis:
AppStore._startPullRequest(desktop/app/src/lib/stores/app-store.ts
Lines 10036 to 10046 in ffeefe5
tipanddefaultBranchfrombranchesStateand always passes the fork's owndefaultBranchinto_initializePullRequestPreview, which then diffscurrentBranchagainst that branch viagitStore.getCommitsBetweenBranches(desktop/app/src/lib/stores/git-store.ts
Lines 1758 to 1764 in ffeefe5
getBranchMergeBaseChangedFiles. Meanwhile,GitStore.refreshDefaultBranch(desktop/app/src/lib/stores/git-store.ts
Lines 469 to 495 in ffeefe5
upstreamDefaultBranchspecifically for forked repos "contributing to the parent," and this value is exposed onbranchesState(desktop/app/src/lib/stores/app-store.ts
Lines 1424 to 1425 in ffeefe5
_startPullRequest. By contrast,_openCreatePullRequestInBrowser(desktop/app/src/lib/stores/app-store.ts
Lines 8705 to 8709 in ffeefe5
showPullRequestPopup's base-branch filtering (desktop/app/src/lib/stores/app-store.ts
Lines 10163 to 10166 in ffeefe5
isForkedRepositoryContributingToParent(repository)before deciding which remote/branch to target. This asymmetry — the actual "Create pull request" browser action and base-branch dropdown account for the fork/upstream distinction, but the initial preview computation does not — is consistent with the reported symptom: the preview diffs against the fork's stalemain, while GitHub itself (and the rest of Desktop's PR UI) correctly resolves against the parent's default branch. If the fork's default branch is behind, this makes every upstream commit appear to be part of the PR in the preview only.tidy-dev commentedon Nov 4, 2026
Could you let us know which fork behavior is selected? In Desktop, open Repository settings → Fork behavior. Under I'll be using this fork…, the options are To contribute to the parent repository and For my own purposes. Which one is selected?
PtJade-Ceramic commentedon Nov 5, 2026
To contribute to the parent repository.
Another problem found out of the scope of this issue
BTW the sidebar there does not respond to Home/End/PageUp/PageDown, which may be reported as another issue.
DylanDevelops commentedon Nov 9, 2026
I believe I fixed this issue in #23151! Let me know if I am understanding the problem correctly.