{"record":{"id":"49e1bb266097fbb4","repo":"pcottle/learnGitBranching","slug":"delete-only-accepts-plain-target-ref-names","errorCode":null,"errorMessage":"--delete only accepts plain target ref names","messagePattern":"--delete only accepts plain target ref names","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/git/commands.js","lineNumber":979,"sourceCode":"        ? 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\n      if (firstArg && isColonRefspec(firstArg)) {\n        if (firstArg[0] == '+') {\n          force = true;\n          firstArg = firstArg.substr(1);\n        }\n        var refspecParts = firstArg.split(':');\n        source = refspecParts[0];\n        destination = validateBranchName(engine, refspecParts[1]);","sourceCodeStart":961,"sourceCodeEnd":997,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/commands.js#L961-L997","documentation":"`git push --delete` only accepts a plain ref name, not a full refspec like `src:dst`. If the first argument contains a colon (isColonRefspec), the app rejects it just like real git.","triggerScenarios":"`git push origin --delete foo:bar` or any colon-containing refspec combined with --delete/-d.","commonSituations":"Mixing refspec syntax (used for force/normal pushes) with deletion syntax; muscle memory from `git push origin :branch`.","solutions":["Pass a plain branch name: `git push origin --delete foo`","For refspec deletion use `git push origin :foo` without --delete"],"exampleFix":"// before\ngit push origin --delete foo:bar\n// after\ngit push origin --delete foo","handlingStrategy":"validation","validationCode":"function isColonRefspec(s) { return s.indexOf(':') !== -1; }\nif (!isColonRefspec(ref)) { /* safe with --delete */ }","typeGuard":"function isValidDeleteTarget(s){ return /^[\\w.\\/-]+$/.test(s) && s.indexOf(':') === -1; }","tryCatchPattern":null,"preventionTips":["Never combine colon refspecs with --delete","Keep delete syntax and refspec syntax separate in muscle memory"],"tags":["git","push","delete","refspec"],"backgroundTag":"git-invalid-refspec","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}