{"record":{"id":"d1d7d2c3f655a2ca","repo":"pcottle/learnGitBranching","slug":"delete-doesn-t-make-sense-without-any-refs","errorCode":null,"errorMessage":"--delete doesn't make sense without any refs","messagePattern":"--delete doesn't make sense without any refs","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/git/commands.js","lineNumber":971,"sourceCode":"      // the arguments it wants as well... get ready!\n      var generalArgs = command.getGeneralArgs();\n\n      // put the commandOption of delete back in the generalArgs\n      // as it is a flag option\n      if(isDelete) {\n        let option = commandOptions['-d'] || commandOptions['--delete'];\n        generalArgs = option[0] === 'origin'\n        ? option.concat(generalArgs)\n        : generalArgs.concat(option);\n      }\n\n      command.twoArgsForOrigin(generalArgs);\n      assertOriginSpecified(generalArgs);\n      var firstArg = generalArgs[1];\n\n      if(isDelete) {\n        if(!firstArg) {\n          throw new GitError({\n            msg: intl.todo(\n              '--delete doesn\\'t make sense without any refs'\n            )\n          });\n        }\n\n        if(isColonRefspec(firstArg)) {\n          throw new GitError({\n            msg: intl.todo(\n              '--delete only accepts plain target ref names'\n            )\n          });\n        }\n\n        // transform delete target ref to delete colon refspec\n        firstArg = \":\"+firstArg;\n      }\n","sourceCodeStart":953,"sourceCodeEnd":989,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/commands.js#L953-L989","documentation":"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.","triggerScenarios":"`git push origin --delete` with no branch name (isDelete true, generalArgs[1] empty).","commonSituations":"Typos or trailing-space entry where the branch to delete is omitted; copy-paste of a truncated command.","solutions":["Add the branch name: `git push origin --delete <branch>`","Use the shorthand `git push origin :<branch>`","Check that arguments survive shell escaping/quoting"],"exampleFix":"// before\ngit push origin --delete\n// after\ngit push origin --delete feature-x","handlingStrategy":"validation","validationCode":"var args = command.getGeneralArgs();\nif (!(args[0] === 'origin' && args[1])) throw new Error('push --delete needs a ref');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always name the branch after --delete","Trim/validate user input before dispatch","Prefer `push origin :branch` shorthand when in doubt"],"tags":["git","push","delete","argument-validation"],"backgroundTag":"git-missing-ref-argument","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}