{"record":{"id":"5889a1ff1c373694","repo":"windmill-labs/windmill","slug":"branch-newbranchname-already-exists-locally","errorCode":null,"errorMessage":"Branch `${newBranchName}` already exists locally, so the current branch `${currentBranch}` was not renamed. Check out the fork branch yourself (e.g. `git checkout ${newBranchName}`).","messagePattern":"Branch `(.+?)` already exists locally, so the current branch `(.+?)` was not renamed\\. Check out the fork branch yourself \\(e\\.g\\. `git checkout (.+?)`\\)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/commands/workspace/fork.ts","lineNumber":391,"sourceCode":"    );\n    throw error;\n  }\n\n\n  const newBranchName = `${WM_FORK_PREFIX}/${clonedBranchName}/${workspaceId}`\n\n  // Rename workflow: turn the current working branch into the fork branch in\n  // place so its commits become the fork's. (Consent was already established —\n  // by `--from-branch`, or the interactive prompt for a non-base branch.)\n  // Otherwise: leave the user on their branch and have them check out a fresh\n  // fork branch.\n  let onForkBranch = false;\n  if (renameCurrent) {\n    if (currentBranch === newBranchName) {\n      onForkBranch = true;\n      log.info(colors.green(`Your current branch is already \\`${newBranchName}\\`.`));\n    } else if (gitBranchExists(newBranchName)) {\n      log.warn(\n        `Branch \\`${newBranchName}\\` already exists locally, so the current branch \\`${currentBranch}\\` was not renamed. ` +\n        `Check out the fork branch yourself (e.g. \\`git checkout ${newBranchName}\\`).`,\n      );\n    } else {\n      renameCurrentGitBranch(newBranchName);\n      onForkBranch = true;\n      log.info(\n        colors.green(\n          `Renamed \\`${currentBranch}\\` → \\`${newBranchName}\\`. Your existing commits are now on the fork branch.`,\n        ),\n      );\n    }\n  }\n\n  const checkoutHint = onForkBranch\n    ? `Created forked workspace ${trueWorkspaceId}. You are on the fork branch \\`${newBranchName}\\` — push it to sync your fork.`\n    : `Created forked workspace ${trueWorkspaceId}. To start contributing to your fork, create and push edits to the branch \\`${newBranchName}\\` by using the command:\n","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/commands/workspace/fork.ts#L373-L409","documentation":"Error \"Branch `${newBranchName}` already exists locally, so the current branch `${currentBranch}` was not renamed. Check out the fork branch yourself (e.g. `git checkout ${newBranchName}`).\" thrown in windmill-labs/windmill.","triggerScenarios":"Thrown at cli/src/commands/workspace/fork.ts:391 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check out the existing fork branch manually: git checkout <fork-branch-name>","Delete or rename the pre-existing conflicting local branch, then re-run the fork command","Inspect both branches with git log --oneline to decide which to keep"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}