Built-in Git extension writes branch.*.vscode-merge-base via git config --add and can wipe remotes from .git/config
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Built-in Git extension `git config --add --local branch.*.vscode-merge-base` can wipe remotes and branch tracking from `.git/config`
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: 1.128.0 (observed via Cursor 3.20.21, commit f089eeabc5f3505d51b43cdf1eca7fbc10de46f43386b70197b1d28fa777e3c7, which vendors `extensions/git`)
- OS Version: Linux x64 6.18.49-1-MANJARO (Manjaro)
- Git Version: 2.55.0 (`/usr/bin/git`)
Related (same write path, milder symptoms):
- https://github.com/microsoft/vscode/issues/244957 (`vscode-merge-base` duplicated)
- https://github.com/microsoft/vscode/issues/333204 (`Repository.setConfig()` always uses `git config --add`)
Those report duplicate keys. This report is worse: the same `git config --add --local` rewrite can leave `.git/config` with no `[remote]` / `[branch]` tracking (and in a sibling repo, a 0-byte config). Objects, refs, and `refs/remotes/*` stay intact. `git pull` then fails with "There is no tracking information for the current branch."
This has recurred for a long time across several local repos. Identity is stored per-repo (`user.email` in `.git/config`), not globally.
## Expected
Switching branches may add `branch..vscode-merge-base`. It must not delete `[remote]`, `branch..remote`, `branch..merge`, or `[user]`.
## Actual
After the built-in Git extension writes merge-base, `.git/config` can lose remotes and upstreams. `git pull` stops working until the file is restored by hand.
Code path (from #333204): `Repository.setConfig()` shells out to `git config --add --local`. `git config` rewrites the whole file. GitHistoryProvider does this on branch switch for `branch..vscode-merge-base`.
## Output → Git (two windows, two sibling repos)
Not the same folder opened twice. Window 1 is the backend repo, window 2 is the frontend repo. I was working in the backend window and asked the agent to change the frontend as well (normal for a bug that spans both repos). Each window's Git extension wrote `vscode-merge-base` into that repo's `.git/config`. Both configs were destroyed.
Window 1 (backend), after checkout to `feature/fix-auth`:
```
2026-09-15 23:21:11.480 [info] [Model][openRepository] Opened repository: …/project/backend
2026-09-15 23:22:08.578 [info] > git config --get --local branch.feature/fix-auth.vscode-merge-base [1ms]
2026-09-15 23:22:08.579 [warning] [Git][config] git config failed: Failed to execute git
2026-09-15 23:22:08.623 [info] > git config --add --local branch.feature/fix-auth.vscode-merge-base origin/dev [3ms]
```
Window 2 (frontend); the same branch name exists in the frontend repo too:
```
2026-09-15 23:22:24.363 [info] [Model][openRepository] Opened repository: …/project/frontend
2026-09-15 23:22:38.040 [info] > git config --get --local branch.feature/fix-auth.vscode-merge-base [1ms]
2026-09-15 23:22:38.040 [warning] [Git][config] git config failed: Failed to execute git
2026-09-15 23:22:38.083 [info] > git config --add --local branch.feature/fix-auth.vscode-merge-base origin/dev [2ms]
```
Later the same session, remotes are gone in both (no `git remote remove` in the log):
```
2026-09-15 23:55:10.304 [info] [Git][getRemotes] No remotes found in the git config file
```
On checkout back to `dev` in the backend window:
```
2026-09-16 00:06:08.957 [info] [Git][getRemotes] No remotes found in the git config file
2026-09-16 00:06:09.004 [info] > git config --get --local branch.dev.vscode-merge-base [1ms]
2026-09-16 00:06:09.005 [warning] [Git][config] git config failed: Failed to execute git
```
## `.git/config` after the wipe
Backend: only the keys I re-added by hand. `[core]`, `[remote]`, and `[branch]` tracking were gone. The `vscode-merge-base` line the extension had just written was also gone:
```
[user]
email = user@example.com
```
Frontend (the other window): **0-byte** `.git/config` (truncated file, not a partial section).
`git pull` then printed:
```
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
git pull
git branch --set-upstream-to=/ dev
```
`refs/remotes/origin/*` (packed-refs) and all local branches were still present. Only the config file was destroyed.
## Steps to Reproduce
This is the normal multi-repo workflow: backend and frontend are separate git repos, each in its own window. A bug often needs changes in both. I work in the backend window and ask the agent to edit the frontend repo as well.
1. Two sibling git repos (`backend` and `frontend`). Remotes and `user.email` live in each repo's local `.git/config` (no global `user.*`). Confirm `git remote -v` and `git pull` work in both.
2. Open each repo in its own window (window A = backend, window B = frontend).
3. In window A, work as usual (edit, switch/create a branch such as `feature/fix-auth`). Optionally ask the agent in window A to change files in the frontend repo. Window B's Git extension still runs against the frontend checkout.
4. Watch Output → Git in each window for:
`git config --add --local branch..vscode-merge-base …`
5. Inspect both `.git/config` files.
Result: one or both configs lose `[remote]` / branch tracking, or become empty (0 bytes). `git pull` fails with "no tracking information." `git status` and refs still work.
Contributor guide
Assessment
This issue has not been assessed yet.