Add checkout pull request in worktree option#8513
Conversation
Co-authored-by: alexr00 <[email protected]>
Co-authored-by: alexr00 <[email protected]>
Co-authored-by: alexr00 <[email protected]>
… naming Co-authored-by: alexr00 <[email protected]>
…l execution Co-authored-by: alexr00 <[email protected]>
…after progress Co-authored-by: alexr00 <[email protected]>
… scope Co-authored-by: alexr00 <[email protected]>
|
I know that initial request was about context menu, but shouldn't it be added to |
|
@IllusionMH that seems fair. @copilot address this:
|
Added the "Checkout in Worktree" option to the CheckoutButton dropdown in the PR Description view in commit fa08fb7. The option appears in the dropdown when the PR is not currently checked out, alongside the existing "Checkout" and "Open Changes" options. |
alexr00
left a comment
There was a problem hiding this comment.
@copilot, creating the worktree fails:
2026-04-17 15:45:04.921 [info] Preparing worktree (new branch 'alexr00/testBackgroundD')
fatal: a branch named 'alexr00/testBackgroundD' already exists
The branch does indeed already exist, I've checked out this PR before.This is common and expected scenario.
Fixed in commit db793c6. The code now checks if the branch already exists locally before calling |
alexr00
left a comment
There was a problem hiding this comment.
- The action to checkout in a worktree doesn't show from the PR overview/description "checkout" button dropdown
- The info notification that shows "open in new window" should be a modal, and it should offer "new window" and "current window"
… worktree Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/b2dbdafb-3aa3-4d09-8555-21772c09c7e9 Co-authored-by: alexr00 <[email protected]>
Addressed in commit 5f65fda:
|
| } | ||
|
|
||
| private checkoutPullRequestInWorktree(message: IRequestMessage<any>): void { | ||
| vscode.commands.executeCommand('pr.pickInWorktree', this._item).then( |
There was a problem hiding this comment.
@copilot We should not be running execute command. Instead, put a function to checkout in a worktree somewhere that pull request overview can import it from.
There was a problem hiding this comment.
Refactored in commit ed22158. Created a standalone checkoutPRInWorktree function in src/github/worktree.ts that can be imported directly by both commands.ts and pullRequestOverview.ts, eliminating the need for executeCommand.
…eckout menu Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/32630df4-6da8-4847-8013-e2fb1dabc1bb Co-authored-by: alexr00 <[email protected]>
Fixed in commit af07a44. The issue was that the PR Description checkout dropdown uses VS Code's native context menu (via |
…ction Agent-Logs-Url: https://github.com/microsoft/vscode-pull-request-github/sessions/ddf40003-0929-42c3-abfb-5abf98150f00 Co-authored-by: alexr00 <[email protected]>
This PR adds a new "Checkout Pull Request in Worktree" option that allows users to check out a PR branch in a git worktree instead of the main working directory. This enables reviewing colleagues' PRs without having to commit current work, stash changes, or deal with merge conflicts.
Summary
The worktree checkout option is available in two places:
Implementation Details
createWorktreeAPI!isWebwhen clauseOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.