{"record":{"id":"d16e4625005e5392","repo":"pcottle/learnGitBranching","slug":"git-error-staging","errorCode":null,"errorMessage":"git-error-staging","messagePattern":"git-error-staging","errorType":"exception","errorClass":"CommandResult","httpStatus":null,"severity":"warning","filePath":"src/js/git/commands.js","lineNumber":609,"sourceCode":"      }\n\n      command.twoArgsImpliedHead(generalArgs);\n      engine.branch(generalArgs[0], generalArgs[1]);\n    }\n  },\n\n  add: {\n    sc: /^ga($|\\s)/,\n    regex: /^git +add($|\\s)/,\n    description: 'Add file contents to the staging area',\n    options: [\n      '-A',\n      '-u'\n    ],\n    execute: function(engine, command) {\n      if (!engine.changesModelEngaged) {\n        // classic graph-only levels have no working directory to stage\n        throw new CommandResult({\n          msg: intl.str('git-error-staging')\n        });\n      }\n      var commandOptions = command.getOptionsMap();\n      var generalArgs = command.getGeneralArgs();\n      // '.', -A and -u all mean \"stage everything\"\n      var stageAll = !!commandOptions['-A'] || !!commandOptions['-u'] ||\n        generalArgs.indexOf('.') !== -1;\n      engine.addFiles(stageAll ? null : generalArgs);\n    }\n  },\n\n  restore: {\n    regex: /^git +restore($|\\s)/,\n    description: 'Restore working tree files',\n    options: [\n      '--staged',\n      '-S'","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/commands.js#L591-L627","documentation":"git add throws CommandResult with git-error-staging when engine.changesModelEngaged is false — classic graph-only levels have no working directory, so there is nothing to stage. CommandResult (not GitError) means it's informational, ending the command gracefully.","triggerScenarios":"Running git add in any classic graph-only level/sandbox (intro, rampup, etc.) where the changes model isn't engaged.","commonSituations":"Mixing commands from the staging tutorial into graph levels; muscle-memory typing git add before commits in the simulator.","solutions":["Skip git add in graph-only levels — git commit works directly","Switch to a level that engages the working-directory model","Check engine.changesModelEngaged before issuing staging commands"],"exampleFix":"// before\ngit add .; git commit -m 'x'   // graph-only level\n// after\ngit commit -m 'x'","handlingStrategy":"validation","validationCode":"if (!engine.changesModelEngaged) { skip('git add not available here'); return; }","typeGuard":"function stagingAvailable(engine) { return !!engine.changesModelEngaged; }","tryCatchPattern":null,"preventionTips":["Detect level type and only surface staging commands when the changes model is on","Teach that graph-only levels commit directly"],"tags":["git","staging","simulation-limit"],"backgroundTag":"operation-not-supported-in-mode","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}