pcottle/learnGitBranching · error · GitError
git-error-options
Error message
git-error-options
What it means
The commit command rejects combining -am with -a, --all, or -m. Real git treats -am as shorthand, so this guard throws git-error-options when both the compound flag and its components are present.
Source
Thrown at src/js/git/commands.js:143
var commandConfig = {
commit: {
sc: /^(gc|git ci)($|\s)/,
regex: /^git +commit($|\s)/,
description: 'Record changes to the repository',
options: [
'--amend',
'-a',
'--all',
'-am',
'-m'
],
execute: function(engine, command) {
var commandOptions = command.getOptionsMap();
command.acceptNoGeneralArgs();
if (commandOptions['-am'] && (
commandOptions['-a'] || commandOptions['--all'] || commandOptions['-m'])) {
throw new GitError({
msg: intl.str('git-error-options')
});
}
var msg = null;
var args = null;
var stageAll = !!(commandOptions['-a'] || commandOptions['--all'] ||
commandOptions['-am']);
if (stageAll && !engine.changesModelEngaged) {
// classic levels have no real staging, so -a is a no-op worth flagging
command.addWarning(intl.str('git-warning-add'));
}
if (commandOptions['-am']) {
args = commandOptions['-am'];
command.validateArgBounds(args, 1, 1, '-am');
msg = args[0];
}View on GitHub (pinned to 5b09d0ff96)
Solutions
- Use only -am 'msg' and drop the duplicate flags
- Or use plain -m with a separate git add
Example fix
// before git commit -am 'msg' -m 'extra' // after git commit -am 'msg'
Defensive patterns
Strategy: validation
Validate before calling
if (opts['-am'] && (opts['-a'] || opts['--all'] || opts['-m'])) { delete opts['-a']; delete opts['--all']; delete opts['-m']; } Prevention
- Canonicalize flags before executing commands
- Don't stack redundant commit flags in aliases
When it happens
Trigger: git commit -am 'msg' -m 'other' or git commit -am --all 'msg' in the simulator.
Common situations: Shell alias or script that already passes -am and appends extra flags; copying long commands from docs.
Related errors
- git-status-nothing-staged
- git-error-exist
- cannot fetch to ' + ref + ' when checked out on ' + ref
- ' + ref + ' is not a branch
- ' + ref + ' is not a remote branch
AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27).
Data as JSON: /api/errors/f330b6e90573c805.
Report an issue: GitHub.