{"record":{"id":"5513e60003f3d473","repo":"eyaltoledano/claude-task-master","slug":"currently-on-default-branch-currentbranch-plea","errorCode":null,"errorMessage":"currently on default branch: ${currentBranch}\nPlease create a feature branch before proceeding.","messagePattern":"currently on default branch: (.+?)\nPlease create a feature branch before proceeding\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/git/adapters/git-adapter.ts","lineNumber":745,"sourceCode":"\t\treturn await this.isDefaultBranch(currentBranch);\n\t}\n\n\t/**\n\t * Ensures the current branch is not a default branch.\n\t * Throws an error if on a default branch.\n\t *\n\t * @returns {Promise<void>}\n\t * @throws {Error} If currently on a default branch\n\t *\n\t * @example\n\t * await git.ensureNotOnDefaultBranch();\n\t * // Safe to perform operations that shouldn't happen on default branches\n\t */\n\tasync ensureNotOnDefaultBranch(): Promise<void> {\n\t\tconst onDefault = await this.isOnDefaultBranch();\n\t\tif (onDefault) {\n\t\t\tconst currentBranch = await this.getCurrentBranch();\n\t\t\tthrow new Error(\n\t\t\t\t`currently on default branch: ${currentBranch}\\n` +\n\t\t\t\t\t`Please create a feature branch before proceeding.`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Checks if the repository has any remotes configured.\n\t *\n\t * @returns {Promise<boolean>} True if remotes exist\n\t *\n\t * @example\n\t * const hasRemote = await git.hasRemote();\n\t * if (!hasRemote) {\n\t *   console.log('No remotes configured');\n\t * }\n\t */\n\tasync hasRemote(): Promise<boolean> {","sourceCodeStart":727,"sourceCodeEnd":763,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/git/adapters/git-adapter.ts#L727-L763","documentation":"GitAdapter.ensureNotOnDefaultBranch throws this when the repository's current branch is the default branch (main/master). It is a guard used before git write operations that must not target the default branch. The thrown Error message embeds the actual current branch name and instructs the user to create a feature branch.","triggerScenarios":"Calling any API that invokes ensureNotOnDefaultBranch() (e.g. commit/push workflows) while the repo HEAD is on 'main' or 'master', as detected by isOnDefaultBranch().","commonSituations":"Fresh clone (checked out on main by default), forgetting to run 'git checkout -b feature/x' before starting work, automation scripts operating directly on the default branch, or a repo whose default branch config changed.","solutions":["Create and switch to a feature branch: git checkout -b feature/my-changes","Re-run the operation from the new branch","If operating on the default branch is intentional, bypass/adjust the guard rather than suppressing the error"],"exampleFix":"// before\nawait gitAdapter.commitChanges(); // throws on main\n// after\nawait gitAdapter.createBranch('feature/my-changes');\nawait gitAdapter.checkoutBranch('feature/my-changes');\nawait gitAdapter.commitChanges();","handlingStrategy":"validation","validationCode":"if (await gitAdapter.isOnDefaultBranch()) {\n  throw new Error(`Create a feature branch first (currently on ${await gitAdapter.getCurrentBranch()})`);\n}","typeGuard":"null","tryCatchPattern":"try {\n  await gitAdapter.ensureNotOnDefaultBranch();\n} catch (e) {\n  if ((e as Error).message.includes('currently on default branch')) {\n    // prompt user to create a feature branch\n  }\n}","preventionTips":["Always create a feature branch immediately after cloning","Add a pre-operation check with isOnDefaultBranch() in automation scripts","Configure repo tooling (husky/lefthook) to block work on main"],"tags":["git","branching","guard"],"backgroundTag":"operation-on-default-branch","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}