{"record":{"id":"40bf497cf4273a39","repo":"windmill-labs/windmill","slug":"could-not-resolve-workspace-from-branch-name-make-40bf49","errorCode":null,"errorMessage":"Could not resolve workspace from branch name. Make sure you are in a git repo with 'workspaces' configured in wmill.yaml.","messagePattern":"Could not resolve workspace from branch name\\. Make sure you are in a git repo with 'workspaces' configured in wmill\\.yaml\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/workspace/merge.ts","lineNumber":252,"sourceCode":"// ---------------------------------------------------------------------------\n// Main merge command\n// ---------------------------------------------------------------------------\n\nasync function mergeWorkspaces(\n  opts: GlobalOptions & {\n    direction?: string;\n    all?: boolean;\n    skipConflicts?: boolean;\n    include?: string;\n    exclude?: string;\n    preserveOnBehalfOf?: boolean;\n    yes?: boolean;\n  }\n): Promise<void> {\n  // 1. Resolve fork workspace\n  const workspace = await tryResolveBranchWorkspace(opts);\n  if (!workspace) {\n    throw new Error(\n      \"Could not resolve workspace from branch name. Make sure you are in a git repo with 'workspaces' configured in wmill.yaml.\"\n    );\n  }\n\n  const token = workspace.token;\n  if (!token) {\n    throw new Error(\"Not logged in. Please run 'wmill workspace add' first.\");\n  }\n\n  const remote = workspace.remote;\n  setClient(\n    token,\n    remote.endsWith(\"/\") ? remote.substring(0, remote.length - 1) : remote\n  );\n\n  const forkWorkspaceId = workspace.workspaceId;\n\n  // 2. Find parent workspace","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/workspace/merge.ts#L234-L270","documentation":"`wmill workspace merge` resolves the fork workspace purely from the current git branch name via `tryResolveBranchWorkspace`. If the branch does not map to a workspace (not a git repo, or no `workspaces` section in wmill.yaml), the merge cannot proceed and this error is thrown at the very first step.","triggerScenarios":"Running `wmill workspace merge` from a directory that is not a git repo, on a branch with no matching entry in wmill.yaml's `workspaces` mapping, or when wmill.yaml has no workspaces config.","commonSituations":"Detached HEAD or freshly created branch not added to wmill.yaml; running the CLI outside the repo; teammates cloning without the shared wmill.yaml workspaces block.","solutions":["Run from the repo root on a branch that is mapped in wmill.yaml's `workspaces` section","Add the branch → workspace mapping to wmill.yaml","Check out the fork branch before merging"],"exampleFix":"# before\n$ wmill workspace merge  # on unmapped branch\n# after (wmill.yaml)\nworkspaces:\n  my-feature:\n    path: [\"my-feature\"]\n    workspace: wm-fork-my-feature","handlingStrategy":"validation","validationCode":"const ws = await tryResolveBranchWorkspace(opts);\nif (!ws) {\n  throw new Error('Current branch does not map to a workspace; check wmill.yaml workspaces.');\n}","typeGuard":"function resolvesToWorkspace(w: Awaited<ReturnType<typeof tryResolveBranchWorkspace>>): w is NonNullable<typeof w> {\n  return w !== null;\n}","tryCatchPattern":"try {\n  await mergeWorkspaces(opts);\n} catch (e) {\n  if (e.message.includes('Could not resolve workspace from branch name')) {\n    log.error('Add a branch→workspace mapping in wmill.yaml.');\n  } else throw e;\n}","preventionTips":["Map every fork branch in wmill.yaml's workspaces section","Run merge only from the repo root","Avoid detached HEAD states when merging"],"tags":["cli","git-branch","configuration","workspace-merge"],"backgroundTag":"unresolved-branch-workspace","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}