pcottle/learnGitBranching · error · GitError
--delete doesn't make sense without any refs
Error message
--delete doesn't make sense without any refs
What it means
Real git errors out when `git push --delete` is given no ref to delete; this simulation mirrors that. The first arg after the refspec parsing is empty, so the deletion target is missing.
Source
Thrown at src/js/git/commands.js:971
// the arguments it wants as well... get ready!
var generalArgs = command.getGeneralArgs();
// put the commandOption of delete back in the generalArgs
// as it is a flag option
if(isDelete) {
let option = commandOptions['-d'] || commandOptions['--delete'];
generalArgs = option[0] === 'origin'
? option.concat(generalArgs)
: generalArgs.concat(option);
}
command.twoArgsForOrigin(generalArgs);
assertOriginSpecified(generalArgs);
var firstArg = generalArgs[1];
if(isDelete) {
if(!firstArg) {
throw new GitError({
msg: intl.todo(
'--delete doesn\'t make sense without any refs'
)
});
}
if(isColonRefspec(firstArg)) {
throw new GitError({
msg: intl.todo(
'--delete only accepts plain target ref names'
)
});
}
// transform delete target ref to delete colon refspec
firstArg = ":"+firstArg;
}
View on GitHub (pinned to 5b09d0ff96)
Solutions
- Add the branch name: `git push origin --delete <branch>`
- Use the shorthand `git push origin :<branch>`
- Check that arguments survive shell escaping/quoting
Example fix
// before git push origin --delete // after git push origin --delete feature-x
Defensive patterns
Strategy: validation
Validate before calling
var args = command.getGeneralArgs();
if (!(args[0] === 'origin' && args[1])) throw new Error('push --delete needs a ref'); Prevention
- Always name the branch after --delete
- Trim/validate user input before dispatch
- Prefer `push origin :branch` shorthand when in doubt
When it happens
Trigger: `git push origin --delete` with no branch name (isDelete true, generalArgs[1] empty).
Common situations: Typos or trailing-space entry where the branch to delete is omitted; copy-paste of a truncated command.
Related errors
- --delete only accepts plain target ref names
- cannot delete branch ' + options.destination + ' which doesn
- You cannot delete main branch on remote!
- ' + branchName + ' is not a branch!
- ' + branchName + ' is not a remote tracking branch! I don't
AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27).
Data as JSON: /api/errors/d1d7d2c3f655a2ca.
Report an issue: GitHub.