Repository: vscode
Issue: Git - Push (and Sync) does not respect remote.pushdefault configuration
Labels: bug,git

Type: <b>Bug</b>

I have a triangular workflow:

* PROJ: my main repository
* FORK: a bare repository
* DEVL: my work directory...

```
upstream      origin
 [PROJ]<----->[FORK]
    \           ^
     \          |
      \ pull    | push
       \        |
        \       |
         \      |
          \     |
           \->[DEVL]
```


# Configuration

I have two remotes defined in my DEVL repository:

```
[remote "origin"]
        url =.../FORK
        fetch = +refs/heads/*:refs/remotes/origin/*
[remote "upstream"]
        url = .../PROJ/.git
        fetch = +refs/heads/*:refs/remotes/upstream/*
```

The DEVL branch `master` communicates with the main repository (`PROJ`):

```
[branch "master"]
        remote = upstream
        merge = refs/heads/master
```

This is for `pull` purposes, and it works just fine...

👉 However, I want my `push` to go to the bare repository (`FORK`):

```
[remote]
        PushDefault = origin
```

# Result/Bug
When I manually push (`git push`), this does indeed work...

But when I use the VS Code `Push` command, or hit the `Sync` button, it still talks to the FORK:

```
> git push upstream master:master
remote: error: refusing to update checked out branch: refs/heads/master  
```

What am I expecting:
The `pushDefault` configuration should overwrite the branch configuration:

`upstream` should be ignored, and replaced by `origin`


VS Code version: Code 1.70.2 (e4503b30fc78200f846c62cf8091b76ff5547662, 2022-08-16T05:35:13.448Z)
OS version: Windows_NT x64 10.0.19044
Modes:
Remote OS version: Linux x64 4.4.0-19041-Microsoft

<details>
<summary>System Info</summary>

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (8 x 2112)|
|GPU Status|2d_canvas: enabled<br>canvas_oop_rasterization: disabled_off<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_renderer: enabled_on<br>video_decode: enabled<br>video_encode: enabled<br>vulkan: disabled_off<br>webgl: enabled<br>webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|23.72GB (9.69GB free)|
|Process Argv|--crash-reporter-id 7f8984d8-a3de-4835-8e4b-0bf20a65d933|
|Screen Reader|no|
|VM|67%|

|Item|Value|
|---|---|
|Remote|WSL: Ubuntu-20.04|
|OS|Linux x64 4.4.0-19041-Microsoft|
|CPUs|Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (8 x 2112)|
|Memory (System)|23.72GB (9.69GB free)|
|VM|67%|
</details><details><summary>Extensions (33)</summary>

Extension|Author (truncated)|Version
---|---|---
vscode-icalendar|af4|1.0.1
Bookmarks|ale|13.3.1
better-cpp-syntax|jef|1.15.19
jupyter-keymap|ms-|1.0.0
remote-containers|ms-|0.245.1
remote-ssh|ms-|0.84.0
remote-ssh-edit|ms-|0.80.0
remote-wsl|ms-|0.66.3
remote-repositories|ms-|0.18.0
vscode-markdownlint|Dav|0.47.0
myst-highlight|Exe|0.11.0
shell-format|fox|7.2.2
plantuml|jeb|2.17.3
bash-ide-vscode|mad|1.14.0
render-crlf|med|1.6.0
git-graph|mhu|1.30.0
vscode-docker|ms-|1.22.1
python|ms-|2022.12.1
vscode-pylance|ms-|2022.8.30
jupyter|ms-|2022.7.1102252217
jupyter-keymap|ms-|1.0.0
jupyter-renderers|ms-|1.0.9
cpptools|ms-|1.11.5
live-server|ms-|0.2.13
powershell|ms-|2022.7.2
vscode-yaml|red|1.9.1
perl|ric|2.3.0
LiveServer|rit|5.7.5
robotframework-lsp|rob|1.0.0
bash-debug|rog|0.3.9
perlcritic|sfo|1.3.8
shellcheck|tim|0.20.0
pdf|tom|1.2.0

(1 theme extensions excluded)

</details><details>
<summary>A/B Experiments</summary>

```
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263cf:30335440
pythondataviewer:30285071
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411cf:30542925
vsaa593:30376534
pythonvs932:30410667
wslgetstarted:30449410
cppdebug:30492333
pylanb8912:30545647
vsclangdf:30486550
c4g48928:30535728
hb751961:30543456
dsvsc012:30540252
azure-dev_surveyonecf:30548226

```

</details>

<!-- generated by issue reporter -->