Pasting a repository page URL (…/tree/main) into Add project → Git URL clones the wrong URL into a folder named after the branch#32667
What happened
Adding a project with Add project → Git URL fails when the pasted URL is a repository page copied from the browser, such as https://github.com/owner/repo/tree/main. T3 passes the page URL to git clone unchanged, and it names the destination folder after the last path segment. Here that's the branch (main), not the repository.
On a remote environment the first attempt cloned into ~/main. Git failed with "repository not found" and left an empty ~/main behind. Later attempts failed with:
| 1 | Source control repository operation cloneRepository failed for unknown: Destination path already exists and is not empty. |
That second error was correct for those attempts, because the destination already existed. But it doesn't say which folder, so the actual cause (the page URL) was hard to spot.
Diagnosis
normalizePastedCloneUrl (packages/client-runtime/src/operations/projects.ts) only expands owner/repo shorthand and returns every other input as is. The web command palette then derives the folder name from the raw input via getCloneDirectoryName, which takes the last path segment.
Git appends /info/refs to the URL it is given, so a page URL only clones on hosts that rewrite it server side. Checked with git ls-remote <url> HEAD against public repositories, plus the folder name T3 suggests:
| Host | Page URL | git | Suggested folder |
|---|---|---|---|
| GitHub | /owner/repo/tree/main | repository '…/tree/main/' not found | main |
| GitHub | /owner/repo/blob/main/README.md | not found | README.md |
| GitLab | /group/project/-/tree/main | unable to update url base from redirection | main |
| Forgejo (Codeberg) | /owner/repo/src/branch/main | not found | main |
| Bitbucket | /workspace/repo/src/master/ | clones the default branch | master |
| Azure DevOps | /org/project/_git/repo?version=GBmain | fine (ref is in the query) | repo |
The provider sources are fine. For example, GitHub's lookup rejects a page URL with "Repositories are named owner/name." Only the raw Git URL source is affected. Mobile's Add Project screen goes through the same normalizePastedCloneUrl.
Steps to reproduce
- Open the command palette → Add project → choose Git URL.
- Paste
https://github.com/pingdotgg/t3code/tree/mainand continue. - The destination defaults to
<base>/main. Press Clone. - The clone fails because git can't find the repository.
Version
0.1.3-nightly.20261026.3740 (desktop app and the remote server). The code is unchanged on main at 25bf84ab.
Environment
Desktop Nightly on macOS (arm64), connected to a remote Linux (x64) server running the same nightly.
Evidence
Remote server trace: ws.rpc.projectClone.start → SourceControlRepositoryService.runClone at 20:47:38 UTC with git.cwd = home, which left an empty ~/main. Later projectClone.start calls failed in prepareDestination with the error above.
Related issues
#31109 covers resolving a non-empty destination. That's a separate problem, but it's the error users hit after the first failed attempt.
Fix applied or workaround
Paste the repository URL itself (https://github.com/owner/repo.git).
Proposed fix: let each source control definition map its own repository page URLs back to the repository URL, and use that when normalizing a pasted clone URL. This clones the default branch. Honouring the branch in a /tree/<ref> URL would need a new contract field and is ambiguous for refs that contain /, so I'd leave that as a separate decision.
Filed by
Claude Opus 5.5 (claude-opus-5-5) in Claude Code, via t3 triage.