microsoft / microsoft/vscode

Clone should offer "Clone again" when a single existing clone is found

Open
#330,819 1 comment 1 reaction 1 assignee Claimed by @lszomoru View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

# Git: Clone should offer "Clone again" when a single existing clone is found

## Description

When running **Git: Clone** for a repository that has already been cloned locally once, VS Code now automatically opens the existing local clone instead of allowing me to choose whether to open it or clone the repository again.

I would like VS Code to offer the same **"Clone again"** option that is already shown when multiple existing clones are found.

For example:

```text
Git: Clone

https://example.com/repo.git

Existing clone found:

repo-a /path/to/repo-a
Clone again
```

Selecting `repo-a` would open the existing clone, while selecting `Clone again` would continue to the destination folder picker as before.

## Current behavior

1. Run `Git: Clone` and clone a repository into `repo-a`.
2. Run `Git: Clone` again with the same repository URL.
3. VS Code detects `repo-a` and immediately opens it.
4. There is no way in the Git Clone UI to clone another copy, such as `repo-b`.

However, if multiple clones of the same repository already exist, VS Code already shows a Quick Pick containing the existing clones and a **"Clone again"** option.

So currently the behavior is inconsistent:

```text
1 existing clone:
→ automatically open it

2+ existing clones:
→ choose existing clone
→ or "Clone again"
```

I would prefer:

```text
1+ existing clones:
→ choose existing clone
→ or "Clone again"
```

## Use case

I frequently work on multiple features/tasks for the same repository in parallel.

For example:

```text
repo-feature-a/
repo-feature-b/
repo-hotfix/
```

Each directory can be on a different branch and can have its own uncommitted changes, dependencies, build output, dev server state, etc.

For this workflow I intentionally use multiple working directories instead of repeatedly switching branches and using `git stash`.

This reduces context-switching mistakes for me and makes parallel development much easier to reason about.

Previously, `Git: Clone` allowed me to select a destination again, so creating another working copy was straightforward.

The current behavior removes that workflow from the VS Code UI and requires falling back to the terminal:

```bash
git clone repo-feature-b
```

## Suggested behavior

When an existing clone is found, always show the existing-repository picker, even if there is only one cached repository.

The existing UI already supports exactly what is needed:

```text

Clone again
```

Looking at the current implementation, `chooseExistingRepository()` already adds the `Clone again` action, but `tryOpenExistingRepository()` bypasses that picker when exactly one existing repository is found.

It would be useful if a single existing clone went through the same picker as multiple existing clones.

Alternatively, a setting could be provided, for example:

```json
"git.cloneExistingRepositoryBehavior": "prompt"
```

with possible behaviors such as:

```text
"open" // current behavior
"prompt" // existing clone(s) + Clone again
"clone" // always continue to destination picker
```

But simply showing the existing Quick Pick for one clone as well would solve the problem for me.

## Related

This is closely related to #48490, which discussed offering a choice between opening an already-known clone and cloning the repository again.

The current implementation appears to implement this choice for multiple existing clones, but not when exactly one clone exists.

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.