{"record":{"id":"8e7187e8a3a893f1","repo":"windmill-labs/windmill","slug":"refusing-to-rename-your-current-branch-current-8e7187","errorCode":null,"errorMessage":"Refusing to rename your current branch \\`${currentBranch}\\` — it is already a fork branch. 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.","messagePattern":"Refusing to rename your current branch \\\\`(.+?)\\\\` — it is already a fork branch\\. 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\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"cli/src/commands/workspace/fork.ts","lineNumber":78,"sourceCode":"\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    }\n    clonedBranchName = opts.fromBranch;\n    renameCurrent = true;\n  } else if (originalBranchIfForked) {\n    // Fork of a fork: link to the original branch; user checks out a new branch.\n    log.info(`You are creating a fork of a fork. The branch will be linked to the original branch this was forked from, i.e. \\`${originalBranchIfForked}\\`, for all settings and overrides.`);\n    clonedBranchName = originalBranchIfForked;\n    renameCurrent = false;\n  } else if (isBaseBranch(currentBranch)) {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/workspace/fork.ts#L60-L96","documentation":"The current branch is itself a fork branch (wm-fork/<base>/<old-id>). Renaming it onto a new fork branch would silently detach the existing fork from its branch mapping, losing the git sync linkage. The CLI blocks this and instead tells you how to fork a fork properly: omit --from-branch, which bases the new fork on the current fork's original branch and creates a fresh branch without renaming.","triggerScenarios":"Running `wmill workspace fork --from-branch <X>` while HEAD is on a branch whose name matches wm-fork/<base>/<id> (i.e. getOriginalBranchForWorkspaceForks returns a value).","commonSituations":"Chaining forks: user already created one fork and now tries to fork it again while still on the fork branch with --from-branch still in the command line from the previous invocation.","solutions":["Omit --from-branch: run plain `wmill workspace fork` from the fork branch to create a fork-of-fork linked to the original base branch","If you meant to fork a different branch, first switch to a non-fork working branch: `git switch <base-or-working-branch>`"],"exampleFix":"// before\ngit switch wm-fork/main/my-feature\nwmill workspace fork --from-branch main  # refusal\n// after\nwmill workspace fork  # fork of a fork, based on original branch 'main'","handlingStrategy":"validation","validationCode":"const WM_FORK_PREFIX = 'wm-fork';\nconst current = execSync('git branch --show-current', { encoding: 'utf8' }).trim();\nif (opts.fromBranch && current.startsWith(`${WM_FORK_PREFIX}/`)) {\n  throw new Error('Already on a fork branch: omit --from-branch to fork the fork.');\n}\nawait createWorkspaceFork(opts, name);","typeGuard":"function isForkBranch(branch: string, prefix = 'wm-fork'): boolean {\n  return branch.startsWith(`${prefix}/`);\n}","tryCatchPattern":"try {\n  await createWorkspaceFork(opts, name);\n} catch (e) {\n  if ((e as Error).message.includes('already a fork branch')) {\n    console.error('Run `wmill workspace fork` without --from-branch to create a fork of the fork.');\n  } else throw e;\n}","preventionTips":["Recognize wm-fork/<base>/<id> branch names before applying git branch -m","To fork a fork, run the command with no --from-branch while on the fork branch","Never rename fork branches manually with git branch -m"],"tags":["git","cli","workspace-fork","nested-fork"],"backgroundTag":"fork-branch-rename-conflict","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"}