{"record":{"id":"91918d589002ab1b","repo":"zed-industries/zed","slug":"git-worktree-list-failed-stderr","errorCode":null,"errorMessage":"git worktree list failed: {stderr}","messagePattern":"git worktree list failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/git/src/repository.rs","lineNumber":2154,"sourceCode":"                }\n            })\n            .boxed()\n    }\n\n    fn branches(&self) -> BoxFuture<'_, Result<BranchesScanResult>> {\n        let git = self.git_binary();\n        self.executor\n            .spawn(async move {\n                let fields = [\n                    \"%(HEAD)\",\n                    \"%(objectname)\",\n                    \"%(parent)\",\n                    \"%(refname)\",\n                    \"%(upstream)\",\n                    \"%(upstream:track)\",\n                    \"%(committerdate:unix)\",\n                    \"%(authorname)\",\n                    \"%(contents:subject)\",\n                ]\n                .join(\"%00\");\n                let args = vec![\n                    \"for-each-ref\",\n                    \"refs/heads/**/*\",\n                    \"refs/remotes/**/*\",\n                    \"--format\",\n                    &fields,\n                ];\n                let output = git.build_command(&args).output().await?;\n\n                let error = if output.status.success() {\n                    None\n                } else {\n                    let error = format_branch_scan_error(&output);\n                    log::warn!(\"failed to get git branches with commit metadata: {error}\");\n                    Some(error.into())\n                };","sourceCodeStart":2136,"sourceCodeEnd":2172,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/git/src/repository.rs#L2136-L2172","documentation":"Enumerates linked worktrees via `git worktree list --porcelain`; a non-zero exit surfaces git's stderr. Causes are in the stderr text: unreadable or broken worktree metadata, a dangling `.git` file in a linked worktree, unsupported git version, or repository ownership/permission failures.","triggerScenarios":"A linked worktree whose `.git` file points to a moved or deleted main repository (`fatal: not a git repository`); corrupt `.git/worktrees/<id>` metadata after moving/deleting worktrees on disk without `git worktree prune`; git older than 2.7 lacking `worktree list --porcelain`; dubious-ownership failures.","commonSituations":"Worktrees relocated or removed with rm instead of `git worktree remove`; main checkout moved while linked worktrees remained; repos copied between machines or restored from backups with stale administrative worktree files.","solutions":["Prune stale worktree metadata: `git worktree prune`, then retry.","Re-register or remove broken linked worktrees (`git worktree remove <path>` or delete the dangling `.git/worktrees/<id>` entry).","Confirm git is >= 2.7 so the porcelain listing exists.","Fix safe.directory/permission issues reported in the appended stderr."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if let Err(e) = repo.worktrees(..).await {\n    if e.to_string().contains(\"worktree list failed\") {\n        // suggest: git worktree prune; verify git >= 2.7; check safe.directory\n    }\n    return Err(e);\n}","preventionTips":["Use `git worktree remove` instead of rm for linked worktrees.","Run `git worktree prune` after moving or deleting worktrees on disk.","Require git >= 2.7 in your environment checks before using worktree features."],"tags":["git","worktree","subprocess","stderr"],"backgroundTag":"git-command-failed","analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}