{"record":{"id":"116c5867fb4c2dbb","repo":"eyaltoledano/claude-task-master","slug":"working-tree-is-not-clean-this-projectpath-sta","errorCode":null,"errorMessage":"working tree is not clean: ${this.projectPath}\nStaged: ${summary.staged}, Modified: ${summary.modified}, Deleted: ${summary.deleted}, Untracked: ${summary.untracked}\nPlease commit or stash your changes before proceeding.","messagePattern":"working tree is not clean: (.+?)\nStaged: (.+?), Modified: (.+?), Deleted: (.+?), Untracked: (.+?)\nPlease commit or stash your changes before proceeding\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/git/adapters/git-adapter.ts","lineNumber":328,"sourceCode":"\t\t};\n\t}\n\n\t/**\n\t * Ensures the working tree is clean before performing operations.\n\t * Throws an error with details if there are uncommitted changes.\n\t *\n\t * @returns {Promise<void>}\n\t * @throws {Error} If working tree is not clean\n\t *\n\t * @example\n\t * await git.ensureCleanWorkingTree();\n\t * // Safe to perform git operations that require clean state\n\t */\n\tasync ensureCleanWorkingTree(): Promise<void> {\n\t\tconst status = await this.git.status();\n\t\tif (!status.isClean()) {\n\t\t\tconst summary = await this.getStatusSummary();\n\t\t\tthrow new Error(\n\t\t\t\t`working tree is not clean: ${this.projectPath}\\n` +\n\t\t\t\t\t`Staged: ${summary.staged}, Modified: ${summary.modified}, ` +\n\t\t\t\t\t`Deleted: ${summary.deleted}, Untracked: ${summary.untracked}\\n` +\n\t\t\t\t\t`Please commit or stash your changes before proceeding.`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Gets the name of the current branch.\n\t *\n\t * @returns {Promise<string>} Current branch name\n\t * @throws {Error} If unable to determine current branch\n\t *\n\t * @example\n\t * const branch = await git.getCurrentBranch();\n\t * console.log(`Currently on: ${branch}`);\n\t */","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/git/adapters/git-adapter.ts#L310-L346","documentation":"ensureCleanWorkingTree() reads simple-git status() and throws when status.isClean() is false, listing counts of staged, modified, deleted, and untracked files. Branch operations (createBranch with checkout, checkoutBranch, createAndCheckoutBranch) and startWorkflow() require a clean tree to avoid mixing uncommitted work into new branches. The error includes the project path and a per-category summary.","triggerScenarios":"Calling createBranch(name, {checkout:true}), checkoutBranch(name), createAndCheckoutBranch(name), or startWorkflow() while the working tree has any staged/unstaged changes or untracked files (and options.force is not set for checkoutBranch).","commonSituations":"Untracked log/build files flagged as changes; developer forgot to commit WIP; CI running on a checkout where the build step generated files before invoking the workflow; .gitignore missing for generated artifacts.","solutions":["Commit your work: git add -A && git commit -m 'wip before workflow'.","Or stash it: git stash -u (includes untracked files).","For checkoutBranch specifically, pass options.force to skip the clean-tree check.","Add generated files to .gitignore so untracked artifacts don't count as changes.","Check the counts in the error message to see which category (e.g. untracked) is blocking and clean accordingly."],"exampleFix":"// before\nawait git.checkoutBranch('feature/x'); // throws: working tree not clean\n// after\nconst clean = await git.isWorkingTreeClean();\nif (!clean) await git.git.raw(['stash', '-u']); // or commit first\nawait git.checkoutBranch('feature/x');","handlingStrategy":"validation","validationCode":"const summary = await git.getStatusSummary();\nconst dirty = summary.staged + summary.modified + summary.deleted + summary.untracked;\nif (dirty > 0) {\n  console.warn(`Tree not clean: ${JSON.stringify(summary)} — commit or stash first`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await git.createAndCheckoutBranch('feature/x');\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('working tree is not clean')) {\n    // offer stash: git stash -u, then retry\n    throw e;\n  }\n  throw e;\n}","preventionTips":["Check isWorkingTreeClean() before any branch operation and prompt to commit/stash.","Add build artifacts and logs to .gitignore so untracked files don't block workflows.","In CI, run workflows before build steps that generate files, or use a pristine checkout.","Use `git stash -u` (include untracked) when you need to clear everything quickly."],"tags":["git","dirty-working-tree","uncommitted-changes"],"backgroundTag":"dirty-working-tree","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}