pcottle/learnGitBranching · warning · CommandResult
git-error-staging
Error message
git-error-staging
What it means
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.
Source
Thrown at src/js/git/commands.js:609
}
command.twoArgsImpliedHead(generalArgs);
engine.branch(generalArgs[0], generalArgs[1]);
}
},
add: {
sc: /^ga($|\s)/,
regex: /^git +add($|\s)/,
description: 'Add file contents to the staging area',
options: [
'-A',
'-u'
],
execute: function(engine, command) {
if (!engine.changesModelEngaged) {
// classic graph-only levels have no working directory to stage
throw new CommandResult({
msg: intl.str('git-error-staging')
});
}
var commandOptions = command.getOptionsMap();
var generalArgs = command.getGeneralArgs();
// '.', -A and -u all mean "stage everything"
var stageAll = !!commandOptions['-A'] || !!commandOptions['-u'] ||
generalArgs.indexOf('.') !== -1;
engine.addFiles(stageAll ? null : generalArgs);
}
},
restore: {
regex: /^git +restore($|\s)/,
description: 'Restore working tree files',
options: [
'--staged',
'-S'View on GitHub (pinned to 5b09d0ff96)
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
Example fix
// before git add .; git commit -m 'x' // graph-only level // after git commit -m 'x'
Defensive patterns
Strategy: validation
Validate before calling
if (!engine.changesModelEngaged) { skip('git add not available here'); return; } Type guard
function stagingAvailable(engine) { return !!engine.changesModelEngaged; } Prevention
- Detect level type and only surface staging commands when the changes model is on
- Teach that graph-only levels commit directly
When it happens
Trigger: Running git add in any classic graph-only level/sandbox (intro, rampup, etc.) where the changes model isn't engaged.
Common situations: Mixing commands from the staging tutorial into graph levels; muscle-memory typing git add before commits in the simulator.
Related errors
- ' + generalArgs[0] + ' is not a remote in your repository! t
- git-error-origin-required
- git-status-nothing-staged
- this.getStatusMsg()
- git-error-exist
AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27).
Data as JSON: /api/errors/d16e4625005e5392.
Report an issue: GitHub.