{"record":{"id":"5c872322397cc81c","repo":"eyaltoledano/claude-task-master","slug":"no-staged-changes-to-commit","errorCode":null,"errorMessage":"no staged changes to commit","messagePattern":"no staged changes to commit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/git/adapters/git-adapter.ts","lineNumber":587,"sourceCode":"\t\t} = {}\n\t): Promise<void> {\n\t\t// Check if on default branch and enforcement is requested\n\t\tif (options.enforceNonDefaultBranch && !options.force) {\n\t\t\tconst currentBranch = await this.getCurrentBranch();\n\t\t\tconst defaultBranches = ['main', 'master', 'develop'];\n\t\t\tif (defaultBranches.includes(currentBranch)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`cannot commit to default branch: ${currentBranch}\\n` +\n\t\t\t\t\t\t`Please create a feature branch or use force option.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// Check for staged changes unless allowEmpty\n\t\tif (!options.allowEmpty) {\n\t\t\tconst hasStaged = await this.hasStagedChanges();\n\t\t\tif (!hasStaged) {\n\t\t\t\tthrow new Error('no staged changes to commit');\n\t\t\t}\n\t\t}\n\n\t\t// Build commit arguments\n\t\tconst commitArgs: string[] = ['commit'];\n\n\t\t// Add message\n\t\tcommitArgs.push('-m', message);\n\n\t\t// Add metadata as separate commit message lines\n\t\tif (options.metadata) {\n\t\t\tcommitArgs.push('-m', ''); // Empty line separator\n\t\t\tfor (const [key, value] of Object.entries(options.metadata)) {\n\t\t\t\tcommitArgs.push('-m', `[${key}:${value}]`);\n\t\t\t}\n\t\t}\n\n\t\t// Add flags","sourceCodeStart":569,"sourceCodeEnd":605,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/git/adapters/git-adapter.ts#L569-L605","documentation":"createCommit() checks hasStagedChanges() before committing and throws this static message when the index has nothing staged and options.allowEmpty is not set. Git itself would reject an empty commit; the adapter surfaces it as a friendly error early. Only changes added to the index count — modified-but-unstaged files do not.","triggerScenarios":"Calling createCommit(message) when nothing has been git-added: files modified but not staged, all changes unstaged, or the working tree is completely clean — without { allowEmpty: true }.","commonSituations":"Automation forgetting to stage files before committing; assuming the adapter auto-stages (it does not); expecting a --allow-empty style commit without passing allowEmpty; a hook or earlier step already consumed the staged changes.","solutions":["Stage changes before committing: git add -A (or stage specific files), then retry.","Pass { allowEmpty: true } if an empty commit is intentional (e.g. triggering CI).","Verify with hasStagedChanges() before committing and stage programmatically if false.","Check `git status` — modified-but-unstaged files still count as 'nothing staged'."],"exampleFix":"// before\nawait git.createCommit('msg'); // throws if nothing staged\n// after\nif (!(await git.hasStagedChanges())) {\n  await git.git.add('./*'); // or stage intended files\n}\nawait git.createCommit('msg');","handlingStrategy":"validation","validationCode":"if (!(await git.hasStagedChanges()) && !allowEmpty) {\n  // stage files here or abort with a clear message\n}","typeGuard":null,"tryCatchPattern":"try {\n  await git.createCommit('msg');\n} catch (e) {\n  if (e instanceof Error && e.message === 'no staged changes to commit') {\n    console.error('Stage files first: git add <files>');\n    return;\n  }\n  throw e;\n}","preventionTips":["Explicitly stage files (git add) before calling createCommit — the adapter never auto-stages.","Check hasStagedChanges() before committing and handle the empty case in UI/automation.","Pass allowEmpty:true only for intentional empty commits (e.g. CI triggers).","Remember unstaged modifications don't count; `git status` shows staged vs unstaged."],"tags":["git","commit","staging","empty-commit"],"backgroundTag":"no-staged-changes","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}