Repository: vscode
Issue: Git - Git fails to switch to remote branch when same name local branch exists
Labels: bug,git

Type: <b>Bug</b>

This was actually reported years ago at https://github.com/Microsoft/vscode/issues/60904 which presumrely was fixed, but I think that fix went to other directions and this issue remains today.

STR:

1. Clone a forked repo.
```
git clone https://github.com/fireattack/nndownload && code nndownload
```

2. Fetch the upstream in terminal.
```
git fetch upstream
```

3. Now, in VS Code UI, click the bottom left branch button, and choose "upstream/master".

Expected: it asks you to choose a name for local branch

Observed: it just throws the error: 

![image](https://github.com/microsoft/vscode/assets/4130991/d4e30698-d7cb-43d8-bde0-f36bd8d59820)


Strictly speaking, this isn't a bug; but I think it should be improved as it is a very common scenario: one want to work on  a fork of a repo while check upstream code from time to time. They want to have two local branches, `master` and, say, `master_upstream` to track each so they can switch between them quickly.

However currently in this scenario, you have to create the branch first and them manually add track to remote. I think ideally VS Code should prompt you to give a different name for local branch and do the rest for you if you want to switch to a remote branch with duplicated name.

VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:13:33.891Z)
OS version: Windows_NT x64 10.0.19045
Modes:

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz (4 x 2904)|
|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: unavailable_off<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled<br>webgpu: enabled|
|Load (avg)|undefined|
|Memory (System)|11.87GB (3.64GB free)|
|Process Argv|nndownload --crash-reporter-id 0e11f8f3-5f57-47d7-a60d-3761aa77f136|
|Screen Reader|no|
|VM|0%|
</details><details><summary>Extensions (70)</summary>

Extension|Author (truncated)|Version
---|---|---
vscode-m3u|af4|1.0.0
vscode-nginx-conf|ahm|0.3.5
Bookmarks|ale|13.5.0
rtf|ale|2.8.0
vscode-json|and|1.5.2
vscode-subtitles|ast|0.4.0
git-exclude|bou|0.4.0
gitignore|cod|0.9.0
curlconverter|cur|0.0.3
githistory|don|0.6.20
xml|Dot|2.5.1
vscode-great-icons|emm|2.1.105
vsc-material-theme-icons|equ|3.6.0
prettier-vscode|esb|10.4.0
copy-relative-path-and-line-numbers|ezf|0.3.1
vscode-open-in-github|fab|2.3.0
copilot|Git|1.195.0
copilot-chat|Git|0.15.2
remotehub|Git|0.62.0
vscode-pull-request-github|Git|0.88.1
go|gol|0.41.4
gc-excelviewer|Gra|4.2.59
beautify|Hoo|1.5.0
vscode-edit-csv|jan|0.9.1
json-escaper|jos|1.1.2
vscode-view-in-browser|kop|1.0.5
autoconf|mae|0.2.0
vscode-autohotkey-plus-plus|mar|5.0.5
rainbow-csv|mec|3.12.0
gitignore|mic|1.0.1
ecdc|mit|1.8.0
autopep8|ms-|2024.0.0
debugpy|ms-|2024.6.0
isort|ms-|2023.10.1
python|ms-|2024.6.0
vscode-pylance|ms-|2024.5.1
remote-containers|ms-|0.362.0
remote-ssh|ms-|0.110.1
remote-ssh-edit|ms-|0.86.0
remote-wsl|ms-|0.88.2
azure-repos|ms-|0.38.0
cpptools|ms-|1.20.5
hexeditor|ms-|1.10.0
remote-explorer|ms-|0.4.3
remote-repositories|ms-|0.40.0
copy-json-path|nid|0.4.0
es6-css-minify|olb|3.3.3
postman-for-vscode|Pos|1.0.3
text-power-tools|qcz|1.47.1
seti-icons|qin|0.1.3
sqlite-viewer|qwt|0.4.14
vscode-yaml|red|1.14.0
vscode-sort-json|ric|1.20.0
rust-analyzer|rus|0.3.1975
code-spell-checker|str|3.0.1
vscode-open-in-github|sys|1.18.0
even-better-toml|tam|0.19.2
pdf|tom|1.2.2
simple-rst|tro|1.5.4
sort-lines|Tyr|1.11.0
vscode-lldb|vad|1.10.0
intellicode-api-usage-examples|Vis|0.2.8
vscodeintellicode|Vis|1.3.1
vscode-icons|vsc|12.7.0
volar|Vue|2.0.8
vscode-todo-highlight|way|1.0.5
highlight-bad-chars|wen|0.0.6
word-divider|yut|0.2.1
save-as-root|yy0|1.8.0
cuesheet|zgm|0.4.0

(3 theme extensions excluded)

</details><details>
<summary>A/B Experiments</summary>

```
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vstes627:30244334
vscorecescf:30445987
vscod805:30301674
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pythonmypyd1:30879173
pythoncet0:30885854
2e7ec940:31000449
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
jchc7451:30973076
chatpanelc:31048052
dsvsc021:30996838
01bff139:31013167
pythoncenvpt:31049070
a69g1124:31058053
dvdeprecation:31052039
pythonprt:31056678
dwnewjupytercf:31046870
26j00206:31048877

```

</details>

<!-- generated by issue reporter -->