[BUG] --worktree flag silently fails for self-hosted Git servers (Gitea, Gogs, etc.)

Resolved 💬 2 comments Opened Feb 24, 2026 by sumin220 Closed Feb 24, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The --worktree (-w) flag silently does nothing when the repository remote points to a self-hosted Git server (e.g., Gitea, Gogs, Forgejo). No error message is displayed — the session starts as a normal session without worktree isolation

Investigation revealed two issues:

  1. Repository URL parser only recognizes standard hosting platforms (Github, GitLab, Bitbucket). For self-hosted servers with custom domains/ports, the parser returns null, causing worktree creation to be skipped entirely
  1. Silent failure with no user feedback. When the parser returns null, the flag is dropped without any warning. Debug logs (457 lines) showed zero worktree-related operations were attempted

On the same machine, a Github repository successfully created a worktree, while the self-hosted Gitea repository always fails silently

What Should Happen?

  1. A git worktree should be created regardless of the remote hosting provider. The underlying git worktree add command works with any remote - the URL parser should not gate this functionality
  1. At minimum, if worktree creation is not possible, Claude Code should display a clear error message instead of silently falling back to a normal session.

For example:

  • Warning: Could not create worktree - unrecognized Git remote URL format
  • Starting normal session instead

Error Messages/Logs

No error messages are shown — that is part of the bug.

Debug log (`/tmp/worktree-debug.log`, 457 lines) contains zero worktree-related operations. The only "worktree" mentions in the log are from memory hook context about past troubleshooting. The flag is silently dropped after repository URL parsing fails.

Steps to Reproduce

Steps to Reproduce

  1. Set up a repository with a self-hosted Gitea remote:

git remote -v
origin https://git.example.com:3000/org/repo.git (fetch)

  1. Run claude --worktree test-feature
  2. Observe: session starts normally, no worktree created
  3. Verify: git worktree list shows only the main working tree
  4. Compare: clone a GitHub repo and run claude --worktree test — works correctly

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.50

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Warp

Additional Information

Current Workaround

Manual git worktree workflow:

```bash
git worktree add ../project-wt-feature -b feature/my-feature
cd ../project-wt-feature
claude

This works but loses the convenience of the --worktree flag.

Suggestion

The git worktree add command itself is hosting-provider-agnostic. Consider
decoupling the worktree creation logic from the repository URL parser, or adding
a fallback path that creates worktrees without requiring URL recognition.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗