microsoft / microsoft/vscode

Copilot Git remote fallback fails for linked worktrees

Open
#334,453 0 comments 0 reactions 1 assignee Claimed by @lszomoru View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

## Symptom

Recent Code Insiders sessions repeatedly log an error when Copilot tries to discover repository remotes for agent-created linked worktrees:

```text
2026-09-02 09:04:43.837 [error] [GitServiceImpl][getRepositoryFetchUrls] Failed to read remotes from .git/config: Error: ENOTDIR: not a directory, open '/.git/config'
```

```text
2026-09-03 09:03:09.012 [error] [GitServiceImpl][getRepositoryFetchUrls] Failed to read remotes from .git/config: Error: ENOTDIR: not a directory, open '/.git/config'
```

## Brief analysis

The fallback in `extensions/copilot/src/platform/git/vscode-node/gitServiceImpl.ts#getRepositoryFetchUrls` assumes the repository config is always at `/.git/config`.

For a linked Git worktree, `.git` is a file containing a `gitdir:` pointer, for example:

```text
gitdir: /.git/worktrees/
```

That administrative directory normally contains a `commondir` file (commonly `../..`) pointing to the shared Git directory where `config` lives. Reading `.git/config` therefore fails with `ENOTDIR`.

The method catches the error and returns `undefined`, so callers such as content-exclusion repository discovery cannot identify the worktree's remotes through this fallback. The fallback should resolve `gitdir` and optional `commondir` metadata before reading the config, while preserving the existing regular-repository path.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.