pcottle/learnGitBranching · error · GitError
Bad numeric argument: ' + generalArgs[1]
Error message
Bad numeric argument: ' + generalArgs[1]
What it means
fakeTeamwork's two-arg form parses generalArgs[1] as a count; parseInt yields NaN so the argument isn't numeric and a GitError with a plain (non-i18n) message is thrown.
Source
Thrown at src/js/git/commands.js:366
branch = 'main';
numToMake = 1;
break;
// git fakeTeamwork 10 or git fakeTeamwork foo
case 1:
if (isNaN(parseInt(generalArgs[0], 10))) {
branch = validateOriginBranchName(engine, generalArgs[0]);
numToMake = 1;
} else {
numToMake = parseInt(generalArgs[0], 10);
branch = 'main';
}
break;
case 2:
branch = validateOriginBranchName(engine, generalArgs[0]);
if (isNaN(parseInt(generalArgs[1], 10))) {
throw new GitError({
msg: 'Bad numeric argument: ' + generalArgs[1]
});
}
numToMake = parseInt(generalArgs[1], 10);
break;
}
// make sure its a branch and exists
var destBranch = engine.origin.resolveID(branch);
if (destBranch.get('type') !== 'branch') {
throw new GitError({
msg: intl.str('git-error-options')
});
}
engine.fakeTeamwork(numToMake, branch);
}View on GitHub (pinned to 5b09d0ff96)
Solutions
- Pass a numeric count: git fakeTeamwork <branch> <number>
- Reorder args — branch first, integer count second
Example fix
// before git fakeTeamwork two main // after git fakeTeamwork main 2
Defensive patterns
Strategy: validation
Validate before calling
var n = parseInt(args[1], 10); if (isNaN(n)) { prompt for a number; return; } Type guard
function isCountArg(s) { return /^\d+$/.test(String(s)); } Prevention
- Enforce numeric input at the command-line parser/UI
- Document arg order: branch then count
When it happens
Trigger: git fakeTeamwork main abc or git fakeTeamwork main two.
Common situations: Passing the branch and count in the wrong order; typing a word instead of a number.
Related errors
- --delete doesn't make sense without any refs
- 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/dc1323297e9e1570.
Report an issue: GitHub.