{"record":{"id":"708c72c0b9c17e2c","repo":"windmill-labs/windmill","slug":"could-not-resolve-workspace-from-branch-name-make","errorCode":null,"errorMessage":"Could not resolve workspace from branch name. Make sure you are in a git repo to use workspace forks","messagePattern":"Could not resolve workspace from branch name\\. Make sure you are in a git repo to use workspace forks","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/workspace/fork.ts","lineNumber":120,"sourceCode":"    clonedBranchName = await resolveWorkingBranchBase(config, opts, currentBranch);\n    renameCurrent = true;\n  }\n\n  // Resolve the parent workspace. When the base differs from the current\n  // branch (the rename workflows), resolve via the base branch's workspace;\n  // otherwise use plain branch resolution.\n  let workspace;\n  if (clonedBranchName === currentBranch) {\n    workspace = await tryResolveBranchWorkspace(opts);\n  } else {\n    const baseMatch = findWorkspaceByGitBranch(config.workspaces, clonedBranchName);\n    workspace = baseMatch\n      ? await tryResolveBranchWorkspace(opts, baseMatch[0])\n      : await tryResolveBranchWorkspace(opts);\n  }\n\n  if (!workspace) {\n    throw new Error(\"Could not resolve workspace from branch name. Make sure you are in a git repo to use workspace forks\");\n  }\n\n  log.info(`You are forking workspace (${workspace.workspaceId})`)\n\n  if (opts.workspace) {\n    log.info(\n      colors.red.bold(\n        \"! Workspace needs to be specified as positional argument, not as option.\"\n      )\n    );\n    return;\n  }\n\n  const token = workspace.token;\n\n  if (!token) {\n    throw new Error(\"Not logged in. Please run 'wmill workspace add' first.\");\n  }","sourceCodeStart":102,"sourceCodeEnd":138,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/workspace/fork.ts#L102-L138","documentation":"After determining the base branch, the CLI must resolve the parent Windmill workspace that the fork will clone. `tryResolveBranchWorkspace` matches the current (or base) git branch against the workspaces in wmill.yaml / the CLI config. If nothing matches — no workspace with a matching gitBranch setting and no explicit workspace context — the fork cannot proceed and this error is thrown.","triggerScenarios":"Running `wmill workspace fork` from a branch that is not mapped to any workspace in the CLI config (and not a fork-of-fork branch), so branch-to-workspace resolution returns undefined.","commonSituations":"Cloned a repo but never ran `wmill workspace add` so wmill.yaml has no workspaces; checked out a brand-new feature branch before mapping it; wmill.yaml missing (config not synced); CI environment lacking the local workspace config.","solutions":["Run `wmill workspace add` to register the workspace and generate/map it to your current branch in wmill.yaml","Switch to the branch that is mapped to the workspace you want to fork, then run the command","Manually add a gitBranch mapping for the current branch under workspaces in wmill.yaml","Pass the workspace explicitly if your CLI version supports it, or use --from-branch with a mapped base branch"],"exampleFix":"// before (unmapped branch)\ngit switch brand-new-branch && wmill workspace fork  # error\n// after\nwmill workspace add https://instance user token  # registers + maps workspace\ngit switch brand-new-branch && wmill workspace fork","handlingStrategy":"validation","validationCode":"const current = execSync('git branch --show-current', { encoding: 'utf8' }).trim();\nconst ws = config.workspaces?.find(w => w.gitBranch === current);\nif (!ws) {\n  throw new Error(`No workspace mapped to branch '${current}'. Run 'wmill workspace add' first.`);\n}\nawait createWorkspaceFork(opts, name);","typeGuard":"function resolveWorkspaceForBranch<T extends { gitBranch?: string }>(branch: string, workspaces: T[] | undefined): T | null {\n  return workspaces?.find(w => w.gitBranch === branch) ?? null;\n}","tryCatchPattern":"try {\n  await createWorkspaceFork(opts, name);\n} catch (e) {\n  if ((e as Error).message.includes('Could not resolve workspace from branch')) {\n    console.error('Register the workspace: `wmill workspace add <remote> <name> <token>`.');\n  } else throw e;\n}","preventionTips":["Run `wmill workspace add` right after cloning a repo","Check out the branch mapped to the workspace you intend to fork","Verify mappings with `wmill workspace list` before forking in CI"],"tags":["git","config","wmill-yaml","workspace-resolution"],"backgroundTag":"branch-workspace-not-resolved","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}