{"record":{"id":"f258bee0c6860f8e","repo":"windmill-labs/windmill","slug":"refusing-to-rename-your-current-branch-current","errorCode":null,"errorMessage":"Refusing to rename your current branch \\`${currentBranch}\\` — it looks like a base branch (mapped to a workspace in wmill.yaml, or main/master). Check out the disposable working branch you want to convert first.","messagePattern":"Refusing to rename your current branch \\\\`(.+?)\\\\` — it looks like a base branch \\(mapped to a workspace in wmill\\.yaml, or main/master\\)\\. Check out the disposable working branch you want to convert first\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/workspace/fork.ts","lineNumber":70,"sourceCode":"    branch === \"master\" ||\n    findWorkspaceByGitBranch(config.workspaces, branch) !== undefined;\n\n  // Decide the base branch the fork links to, and whether to rename the\n  // current working branch onto the fork branch. Auto-detected from where you\n  // are; `--from-branch` is the explicit/non-interactive override.\n  let clonedBranchName: string;\n  let renameCurrent: boolean;\n\n  if (opts.fromBranch) {\n    // Explicit override: base on <fromBranch>, rename the current branch.\n    if (opts.fromBranch === currentBranch) {\n      throw new Error(\n        `--from-branch is for converting a *different* working branch into the fork branch, but you are already on \\`${currentBranch}\\`. ` +\n        `Omit --from-branch to create a fresh fork branch with \\`git checkout -b\\`.`,\n      );\n    }\n    if (isBaseBranch(currentBranch)) {\n      throw new Error(\n        `Refusing to rename your current branch \\`${currentBranch}\\` — it looks like a base branch (mapped to a workspace in wmill.yaml, or main/master). ` +\n        `Check out the disposable working branch you want to convert first.`,\n      );\n    }\n    if (getOriginalBranchForWorkspaceForks(currentBranch)) {\n      // Current branch is itself a fork branch (wm-fork/<base>/<old-id>).\n      // Renaming it onto the new fork branch would detach the existing fork.\n      throw new Error(\n        `Refusing to rename your current branch \\`${currentBranch}\\` — it is already a fork branch. ` +\n        `To fork a fork, omit --from-branch: \\`wmill workspace fork\\` bases the new fork on this fork's original branch and creates a fresh fork branch without renaming.`,\n      );\n    }\n    if (!findWorkspaceByGitBranch(config.workspaces, opts.fromBranch)) {\n      throw new Error(\n        `Could not find a workspace mapped to branch \\`${opts.fromBranch}\\` in wmill.yaml's workspaces section. ` +\n        `Pass the base branch your fork should be based on (e.g. the branch bound to the parent workspace).`,\n      );\n    }","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/workspace/fork.ts#L52-L88","documentation":"With `--from-branch`, the CLI renames the current branch into the fork branch (git branch -m). Renaming a 'base branch' — one mapped to a workspace in wmill.yaml or the conventional main/master — would rebind the workspace-to-branch mapping and break the git sync workflow. The guard `isBaseBranch(currentBranch)` throws before any rename happens.","triggerScenarios":"Running `wmill workspace fork --from-branch <other>` while the current branch is `main`, `master`, or a branch mapped to a workspace in wmill.yaml's workspaces section.","commonSituations":"Trying to fork while still sitting on main instead of a feature branch; wmill.yaml maps several branches to workspaces and the user forgot which one they are on; habit of running fork from the default checkout branch.","solutions":["Check out the disposable working branch you want to convert first: `git switch <working-branch>`, then run the fork command with --from-branch","If you want a fresh fork branch instead, omit --from-branch (allowed from a base branch) and the CLI will `git checkout -b` a new fork branch","Rename or unmap the branch in wmill.yaml only if you truly intend to rebind the base workspace"],"exampleFix":"// before\ngit switch main\nwmill workspace fork --from-branch develop  # refusal\n// after\ngit switch my-experimental-branch\nwmill workspace fork --from-branch develop","handlingStrategy":"validation","validationCode":"const current = execSync('git branch --show-current', { encoding: 'utf8' }).trim();\nconst isBase = current === 'main' || current === 'master' || config.workspaces.some(w => w.gitBranch === current);\nif (opts.fromBranch && isBase) {\n  throw new Error(`Check out a disposable working branch before using --from-branch (on ${current}).`);\n}\nawait createWorkspaceFork(opts, name);","typeGuard":"function isBaseBranch(branch: string, workspaces: { gitBranch?: string }[]): boolean {\n  return branch === 'main' || branch === 'master' || workspaces.some(w => w.gitBranch === branch);\n}","tryCatchPattern":"try {\n  await createWorkspaceFork(opts, name);\n} catch (e) {\n  if ((e as Error).message.includes('looks like a base branch')) {\n    console.error('git switch to your working branch first, then retry with --from-branch.');\n  } else throw e;\n}","preventionTips":["Never sit on main/master when converting a branch with --from-branch","Keep wmill.yaml branch mappings in mind before renaming branches","From a base branch, omit --from-branch to get a fresh fork branch via checkout -b"],"tags":["git","cli","branch-protection"],"backgroundTag":"protected-base-branch-rename","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"}