Fast-forward existing behind-only branches during PR checkout - #8903
Merged
Alex Ross (alexr00) merged 3 commits intoAug 27, 2026
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with checkout pull request creating new branch
Fast-forward existing behind-only branches during PR checkout
Aug 26, 2026
Alex Ross (alexr00)
marked this pull request as ready for review
August 27, 2026 11:55
Alex Ross (alexr00)
approved these changes
Aug 27, 2026
Alex Ross (alexr00)
enabled auto-merge (squash)
August 27, 2026 11:56
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the “Checkout Pull Request” flow to reuse an existing local PR head branch when it’s only behind the remote (safe fast-forward), instead of always creating a generated pr/<author>/<number> branch whenever SHAs differ. It also adds regression tests to ensure behind-only branches are pulled and associated with the PR without generating a new branch.
Changes:
- Reuse and fast-forward an existing behind-only local branch that tracks the PR head, rather than creating
pr/<author>/<number>. - Add tests covering: behind-only branch checkout + pull, behind-only already-checked-out pull, and a worktree scenario where a unique branch is used.
Show a summary per file
| File | Description |
|---|---|
| src/github/pullRequestGitHelper.ts | Adds “behind-only + tracking” detection to allow fast-forwarding the existing branch during PR checkout. |
| src/test/github/pullRequestGitHelper.test.ts | Adds regression tests validating the new checkout/fast-forward behavior and worktree handling. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Lite
Dirk Bäumer (dbaeumer)
approved these changes
Aug 27, 2026
Alex Ross (alexr00)
deleted the
copilot/fix-checkout-pull-request-issue
branch
August 27, 2026 13:19
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Checkout Pull Request created a
pr/<author>/<number>branch whenever the local and remote SHAs differed—even when the existing local branch was only behind. This left the expected branch stale and associated the PR with the generated branch.pr/<author>/<number>.