-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Description
Type: Bug
Summary
When performing a rebase via VS Code's Source Control UI from a worktree window, three
things went wrong:
-
Wrong branch rebased: I checked out
feature/refactoringand asked to rebase it
ontofeature/container-phase0. Instead, VS Code rebasedfeature/A(a different branch)
ontofeature/container-phase0. In a normalgit rebase, the currently checked-out branch
is the one that gets rebased — VS Code ignored the checked-out branch and rebased the
worktree's prior branch instead. -
Operations dispatched to wrong worktrees: Instead of confining all git operations to
the worktree where I initiated the rebase, VS Code rancheckout,reset, andrebase
across three different worktrees. -
Uncommitted changes destroyed: A
git reset HEADwas executed in an unrelated
worktree that had uncommitted work, permanently destroying those changes.
Setup
A single repository with multiple worktrees:
~/repo/ → main checkout, on branch `development` (had uncommitted changes)
~/repo.worktrees/wt-A/ → worktree on branch `feature/A`
~/repo.worktrees/wt-B/ → worktree on branch `issue/B` (had uncommitted changes)
~/repo.worktrees/wt-C/ → worktree on branch `other-edits`
I had two VS Code windows open:
- The main repo (
~/repo/) on branchdevelopment— had uncommitted changes - Worktree
wt-A(~/repo.worktrees/wt-A/) on branchfeature/A
From the wt-A window, I checked out branch feature/refactoring and asked VS Code to
rebase it on top of feature/container-phase0.
What I expected
A standard git rebase feature/container-phase0 while feature/refactoring is checked out:
- The currently checked-out branch (
feature/refactoring) gets rebased onto
feature/container-phase0 - All operations happen within
wt-Aonly - No other worktree is touched
What actually happened (reconstructed from git reflog)
VS Code did not rebase the checked-out branch. Instead, it scattered operations across
three worktrees and rebased a completely different branch:
Main repo (~/repo/) — should NOT have been touched
| Time | Reflog entry |
|---|---|
| 16:24:24 | checkout: moving from development to feature/container-phase0 |
| 16:25:45 | checkout: moving from feature/container-phase0 to development |
The main repo HEAD was moved to feature/container-phase0 and back. Any uncommitted
changes that conflicted with this checkout would have been silently dropped.
Worktree wt-A (~/repo.worktrees/wt-A/) — where I initiated the rebase
| Time | Reflog entry |
|---|---|
| 16:27:36 | checkout: moving from feature/A to feature/container-phase0 |
| 16:27:51 | pull --autostash origin feature/container-phase0: Fast-forward |
| 16:28:15 | checkout: moving from feature/container-phase0 to feature/A |
| 16:30:24 | rebase (start): checkout feature/container-phase0 |
| 16:30:25 | rebase (pick): … |
| 16:30:25 | rebase (finish): returning to refs/heads/feature/A |
The rebase landed on feature/A — but I had checked out feature/refactoring and
wanted to rebase that branch. VS Code rebased the worktree's prior branch instead of
the branch I actually had checked out. From the rebase's perspective, the "incoming"
commits were picked from the wrong branch entirely.
Worktree wt-B (~/repo.worktrees/wt-B/) — completely unrelated, had uncommitted work
| Time | Reflog entry |
|---|---|
| 16:29:27 | reset: moving to HEAD ← this destroyed my uncommitted changes |
| 16:29:28 | checkout: moving from issue/B to feature/refactoring |
| 16:32:44 | checkout: moving from feature/refactoring to issue/B |
VS Code ran git reset HEAD and git checkout feature/refactoring in wt-B — a worktree
I was not interacting with at all. The reset: moving to HEAD discarded all uncommitted
modifications in that worktree. It appears VS Code intended to check out feature/refactoring
here rather than rebase it — as if the "rebase" operation was decomposed into a checkout in
one worktree and a rebase in another, with the checkout targeting an arbitrary worktree and
the rebase targeting the wrong branch.
Impact
- Uncommitted changes in
wt-Bwere permanently destroyed (partially recovered via
VS Code's local Timeline feature, but only up to the last save — any unsaved
edits between saves were lost) - The rebase was applied to the wrong branch (
feature/Ainstead offeature/refactoring) - The main repo HEAD was unexpectedly moved
- The entire operation should have been scoped to a single worktree
Expected behavior
- A rebase should operate on the currently checked-out branch, consistent with
howgit rebaseworks on the command line - All git operations triggered from a worktree VS Code window should execute exclusively
within that worktree - If VS Code must touch another worktree for any reason, it should detect uncommitted
changes and refuse/warn before proceeding, or at minimum stash them
Related issues
- If multiple instances of VSCode are opened for different git worktrees, the git editor is opened in the main worktree VSCode instance #290708 — git editor opens in main worktree instead of active worktree (same root cause:
operations dispatched to wrong worktree) git commitwith git configcore.editor = code --waitopens in window for main git worktree instead of active window #299540 —git commitwithcore.editor = code --waitopens in wrong window- After resolving all conflicts during a rebase, continue the rebase #249596 — rebase continuation broken in worktrees
- Git - Support git worktrees in workspace #68038 — original worktree support tracking issue
VS Code version: Code 1.112.0 (07ff9d6, 2026-03-17T18:09:23Z)
OS version: Windows_NT x64 10.0.26200
Modes:
Remote OS version: Linux x64 6.6.87.2-microsoft-standard-WSL2
Remote OS version: Linux x64 6.6.87.2-microsoft-standard-WSL2
Remote OS version: Linux x64 6.6.87.2-microsoft-standard-WSL2
Remote OS version: Linux x64 6.6.87.2-microsoft-standard-WSL2
System Info
| Item | Value |
|---|---|
| CPUs | 13th Gen Intel(R) Core(TM) i7-13850HX (28 x 2304) |
| GPU Status | 2d_canvas: enabled GPU0: VENDOR= 0x10de, DEVICE=0x27bb [NVIDIA RTX 3500 Ada Generation Laptop GPU], DRIVER_VENDOR=NVIDIA, DRIVER_VERSION=32.0.15.8195 ACTIVE GPU1: VENDOR= 0x8086, DEVICE=0xa788 [Intel(R) UHD Graphics], DRIVER_VERSION=32.0.101.7080 GPU2: VENDOR= 0x1414, DEVICE=0x008c [Microsoft Basic Render Driver], DRIVER_VERSION=10.0.26100.7309 Machine model name: Machine model version: direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off trees_in_viz: disabled_off video_decode: enabled video_encode: enabled webgl: enabled webgl2: enabled webgpu: enabled webnn: disabled_off |
| Load (avg) | undefined |
| Memory (System) | 31.69GB (8.09GB free) |
| Process Argv | --crash-reporter-id 0ee9c5df-6520-4de7-8875-9c23c4ea84c3 |
| Screen Reader | no |
| VM | 0% |
| Item | Value |
|---|---|
| Remote | WSL: Ubuntu |
| OS | Linux x64 6.6.87.2-microsoft-standard-WSL2 |
| CPUs | 13th Gen Intel(R) Core(TM) i7-13850HX (28 x 0) |
| Memory (System) | 15.46GB (8.15GB free) |
| VM | 0% |
| Item | Value |
|---|---|
| Remote | WSL: Ubuntu |
| OS | Linux x64 6.6.87.2-microsoft-standard-WSL2 |
| CPUs | 13th Gen Intel(R) Core(TM) i7-13850HX (28 x 0) |
| Memory (System) | 15.46GB (8.16GB free) |
| VM | 0% |
| Item | Value |
|---|---|
| Remote | WSL: Ubuntu |
| OS | Linux x64 6.6.87.2-microsoft-standard-WSL2 |
| CPUs | 13th Gen Intel(R) Core(TM) i7-13850HX (28 x 0) |
| Memory (System) | 15.46GB (8.15GB free) |
| VM | 0% |
| Item | Value |
|---|---|
| Remote | WSL: Ubuntu |
| OS | Linux x64 6.6.87.2-microsoft-standard-WSL2 |
| CPUs | 13th Gen Intel(R) Core(TM) i7-13850HX (28 x 0) |
| Memory (System) | 15.46GB (8.15GB free) |
| VM | 0% |
A/B Experiments
vsliv368cf:30146710
pythonvspyt551:31249599
binariesv615:30325510
nativeloc1:31344060
dwcopilot:31170013
dwoutputs:31242946
copilot_t_ci:31333650
e5gg6876:31282496
pythonrdcb7:31342333
6518g693:31463988
aj953862:31281341
6abeh943:31336334
envsdeactivate2:31464701
cloudbuttont:31379625
aihoversummaries_f:31469309
3efgi100_wstrepl:31403338
839jf696:31457053
use-responses-api:31390855
je187915:31401257
ec5jj548:31422691
cp_cls_t_966_ss:31454198
4je02754:31466945
find_all_ref_in_bg_t:31469306
c3h7c220:31478652
ge8j1254_inline_auto_hint_haiku:31431912
38bie571_auto:31478677
cp_cls_t_1081:31454832
ia-use-proxy-models-svc:31452481
a43f0574:31442827
e9c30283:31461165
test_treatment2:31471001
control_6dc23131:31467998
idci7584:31464702
notips:31471632
ei9d7968:31458072
534a6447_copy:31478748
7ef87755:31458076
nes-extended-on:31455476
chat:31457767
8hig5102:31480529
8a2c4887_5_3_codex_prompt:31475326
bg_compact_c:31481651
c-off:31481340
cpptoolson-v2:31475363
thinking_effort_h:31478170
editor1:31474144
c3257622:31473910
h08i8180_copy:31475368
ddid_t:31478206
nes-perm-reb-0:31481661