{"record":{"id":"3281b2a690b15168","repo":"pcottle/learnGitBranching","slug":"cannot-delete-branch-options-destination-w","errorCode":null,"errorMessage":"cannot delete branch ' + options.destination + ' which doesn't exist","messagePattern":"cannot delete branch ' \\+ options\\.destination \\+ ' which doesn't exist","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/git/commands.js","lineNumber":999,"sourceCode":"              '--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]);\n        if (source === \"\" && !engine.origin.resolveID(destination)) {\n          throw new GitError({\n            msg: intl.todo(\n              'cannot delete branch ' + options.destination + ' which doesn\\'t exist'\n            )\n          });\n        }\n      } else {\n        if (firstArg) {\n          // we are using this arg as destination AND source. the dest branch\n          // can be created on demand but we at least need this to be a source\n          // locally otherwise we will fail\n          assertIsRef(engine, firstArg);\n          sourceObj = engine.resolveID(firstArg);\n        } else {\n          // since they have not specified a source or destination, then\n          // we source from the branch we are on (or HEAD)\n          sourceObj = engine.getOneBeforeCommit('HEAD');\n        }\n        source = sourceObj.get('id');","sourceCodeStart":981,"sourceCodeEnd":1017,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/commands.js#L981-L1017","documentation":"When deleting via an empty-source refspec (`:branch`), git checks the destination branch exists on the remote. Here origin.resolveID(destination) fails to find the branch on the simulated remote, so deletion is refused. Note: the message interpolates options.destination which may be stale — a cosmetic bug worth knowing.","triggerScenarios":"`git push origin :<branch>` (or --delete <branch>) where <branch> does not exist on origin; e.g. it was never pushed or already deleted.","commonSituations":"Trying to delete a remote branch that was already removed; deleting a local-only branch name that was never pushed.","solutions":["List remote branches first: `git branch -r` to confirm the name","Fetch/re-clone so o/ tracking refs reflect the remote state","If already deleted, no action is needed"],"exampleFix":"// before\ngit push origin :feature-x  // feature-x not on origin\n// after\ngit branch -r               // verify, then\ngit push origin :feature-x","handlingStrategy":"validation","validationCode":"if (engine.origin.resolveID(destination)) { /* safe to delete */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check `git branch -r` (engine.origin refs) before remote deletes","Fetch to sync o/ refs after out-of-band changes","Skip delete if the branch is already gone"],"tags":["git","push","delete","branch-not-found"],"backgroundTag":"git-remote-branch-not-found","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}