Add git worktree switching to Git Tree Compare view#145
Conversation
|
@copilot resolve the merge conflicts in this pull request |
|
This only seems to happen when having a workspace with multiple root folders open. In this case it also doesn't work well with "Change repository", it gets confused between the repos. If it's only a single root folder then all works fine. |
|
i use git worktree manager for fast change between worktrees. and git tree compare for compare all commits/untracked files with main. onelove ) |
|
I fixed the conflicts since copilot doesnt seem to work |
|
@filoucool Were you able to repro this?
|
@letmaik Thanks for narrowing this down! That explains why I couldn't reproduce. I tested with a single root folder on both native Windows and WSL Ubuntu. Multi root workspaces aren't handled well yet: getWorkspaceRepositoryRoot() picks the first SCM repo, which can confuse Change Repository / Change Worktree, and toGitUri may resolve against the wrong registered repo when opening diffs. Open File works because it only uses a file: URI. Opening the file first likely registers it with the Git extension, which is why the diff works afterward. There's an open PR that may address this more broadly: #139 – Add multi-repository tree view. It adds per repository state for multi-root workspaces, which seems like the right direction for this issue. I'd prefer to log this as a separate issue or wait for #139 to merge before adding worktree specific multi root handling. |


Hi,
This PR adds support for viewing diffs across linked git worktrees directly from the Git Tree Compare view. When working with multiple worktrees, you can switch between them without opening each one as a separate workspace window. I've been using this in my custom build for a while now and recently decided to clean this up as well and share it with the community.
What it does
Changes
Note
Automatic refresh only watches files inside the VS Code workspace folder. If you need to view a worktree outside the workspace, you need to use Refresh to show changes.
Tests
List of available worktrees:
New button to go back to working tree:
When trying to switch from a worktree to another worktree, working tree is always shown on top: