[BUG] --worktree flag silently fails for self-hosted Git servers (Gitea, Gogs, etc.)
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:
- 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
- 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?
- A git worktree should be created regardless of the remote hosting provider. The underlying
git worktree addcommand works with any remote - the URL parser should not gate this functionality
- 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
- Set up a repository with a self-hosted Gitea remote:
git remote -v
origin https://git.example.com:3000/org/repo.git (fetch)
- Run
claude --worktree test-feature - Observe: session starts normally, no worktree created
- Verify:
git worktree listshows only the main working tree - 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.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗