Hmbown/CodeWhale · error
new worktree requires a Git repository
Error message
new worktree requires a Git repository
What it means
Raised in launch_worktree_spec when `git rev-parse --show-toplevel` run in the workspace exits unsuccessfully, meaning the workspace is not inside a Git repository. Creating a worktree requires a repository root to anchor the new worktree's location, so provisioning is refused for plain directories.
Source
Thrown at crates/tui/src/tui/ui/session_state.rs:566
}
if slug.is_empty() {
format!("session-{}", chrono::Utc::now().format("%Y%m%d-%H%M%S"))
} else {
slug
}
}
pub(crate) fn launch_worktree_spec(
workspace: &std::path::Path,
requested: &str,
) -> Result<codewhale_lane::WorktreeProvision> {
let output = std::process::Command::new("git")
.current_dir(workspace)
.args(["rev-parse", "--show-toplevel"])
.output()
.context("inspect Git repository for new worktree")?;
if !output.status.success() {
anyhow::bail!("new worktree requires a Git repository");
}
let repo_root = PathBuf::from(String::from_utf8(output.stdout)?.trim());
let repo_name = repo_root
.file_name()
.and_then(|name| name.to_str())
.filter(|name| !name.is_empty())
.unwrap_or("workspace");
let slug = launch_worktree_slug(requested);
let parent = repo_root.parent().unwrap_or(repo_root.as_path());
let path = parent
.join(".codewhale-worktrees")
.join(format!("{repo_name}-{slug}"));
if path.exists() {
anyhow::bail!("worktree path already exists: {}", path.display());
}
Ok(codewhale_lane::WorktreeProvision {
repo_root,
branch: format!("codex/{slug}"),View on GitHub (pinned to 0c42157ee5)
Solutions
- Run the worktree launch from inside a Git repository
- Initialize Git in the workspace with git init if it should be a repo
- Verify the working directory is the intended project checkout
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/tui/src/tui/ui/session_state.rs:566 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/20dac4fdde1dee74.
Report an issue: GitHub.