Repository: vscode
Issue: Git Issue
Labels: info-needed,git


Type: <b>Bug</b>

Bug Title: Files from the new branch persist after switching back to main

Description:
When switching from a newly created branch back to the main branch, files added in the new branch remain in the working directory. These files should not persist in the main branch unless explicitly committed and merged.

Steps to Reproduce:

1. Check out a new branch: git checkout -b new-branch.
2. Add new files to the working directory in the new branch.
3. Push the changes to the origin: git push origin new-branch.
4. Switch back to the main branch: git checkout main.

Expected Result:
The files added in the new branch should not appear in the working directory when back on the main branch.

Actual Result:
Files from the new branch remain in the working directory after switching back to the main branch.

Environment:

Git Version: 2.47.1
Operating System: macOS Version 14.6.1 (23G93)

VS Code version: Code 1.96.2 (Universal) (fabdb6a30b49f79a7aba0f2ad9df9b399473380f, 2024-12-19T10:22:47.216Z)
OS version: Darwin arm64 23.6.0
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Apple M2 (8 x 2400)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: enabled_on<br>direct_rendering_display_compositor: disabled_off_ok<br>gpu_compositing: enabled<br>multiple_raster_threads: enabled_on<br>opengl: enabled_on<br>rasterization: enabled<br>raw_draw: disabled_off_ok<br>skia_graphite: disabled_off<br>video_decode: enabled<br>video_encode: enabled<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled<br>webnn: disabled_off|
|Load (avg)|2, 2, 2|
|Memory (System)|8.00GB (0.17GB free)|
|Process Argv|--crash-reporter-id 9df8cd10-70de-4a2e-a4ff-e4dd6be4fad6|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (35)</summary>

Extension|Author (truncated)|Version
---|---|---
vscode-tailwindcss|bra|0.12.17
dart-code|Dar|3.102.0
flutter|Dar|3.102.0
prettier-vscode|esb|11.0.0
figma-vscode-extension|fig|0.4.0
copilot|Git|1.256.0
copilot-chat|Git|0.23.2
vscode-github-actions|git|0.27.0
go|gol|0.44.0
terraform|has|2.34.2
azure-dev|ms-|0.8.4
vscode-azureappservice|ms-|0.25.4
vscode-azurecontainerapps|ms-|0.7.1
vscode-azurefunctions|ms-|1.16.1
vscode-azureresourcegroups|ms-|0.10.2
vscode-azurestaticwebapps|ms-|0.12.2
vscode-azurestorage|ms-|0.16.1
vscode-azurevirtualmachines|ms-|0.6.6
vscode-cosmosdb|ms-|0.24.1
vscode-docker|ms-|1.29.3
black-formatter|ms-|2024.4.0
debugpy|ms-|2024.14.0
isort|ms-|2023.10.1
python|ms-|2024.22.2
vscode-pylance|ms-|2024.12.1
remote-containers|ms-|0.394.0
azure-account|ms-|0.12.0
vscode-node-azure-pack|ms-|1.2.0
vscode-typescript-next|ms-|5.8.20250109
vsliveshare|ms-|1.0.5948
vscode-react-native|msj|1.13.0
inline-html|pus|0.3.10
LiveServer|rit|5.7.9
vscode-gradle|vsc|3.16.4
vscode-todo-highlight|way|1.0.5


</details><details>
<summary>A/B Experiments</summary>

```
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythonnoceb:30805159
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
dvdeprecation:31068756
dwnewjupytercf:31046870
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc1:31192215
cf971741:31144450
iacca1:31171482
notype1cf:31157160
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624

```

</details>

<!-- generated by issue reporter -->