{"record":{"id":"af0422c4d22f6627","repo":"pcottle/learnGitBranching","slug":"fatal-not-a-branch-oldname","errorCode":null,"errorMessage":"fatal: not a branch: ' + oldName","messagePattern":"fatal: not a branch: ' \\+ oldName","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/git/index.js","lineNumber":2821,"sourceCode":"  }\n\n  // then join\n  throw new CommandResult({\n    msg: foundTag + '-' + numAway.length + '-g' + startCommit.get('id')\n  });\n};\n\nGitEngine.prototype.renameBranch = function(oldName, newName, force) {\n  var target = this.resolveID(oldName);\n\n  if (!target || target.get('type') !== 'branch') {\n    throw new GitError({\n      msg: intl.todo('fatal: not a branch: ' + oldName)\n    });\n  }\n\n  if (target.getIsRemote()) {\n    throw new GitError({\n      msg: intl.str('git-error-remote-branch')\n    });\n  }\n\n  newName = this.validateBranchName(newName);\n\n  if (this.doesRefExist(newName)) {\n    if (!force) {\n      throw new GitError({\n        msg: intl.todo(\"fatal: A branch named '\" + newName + \"' already exists.\")\n      });\n    }\n    var existing = this.resolveID(newName);\n    if (existing.get('type') !== 'branch') {\n      throw new GitError({\n        msg: intl.str('git-error-options')\n      });\n    }","sourceCodeStart":2803,"sourceCodeEnd":2839,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/index.js#L2803-L2839","documentation":"Duplicate of error 65: the 'fatal: not a branch: <name>' GitError thrown by renameBranch when the old name does not resolve to a branch. The listed SOURCE message string is just the expression used to build the message; the condition is !target || target.get('type') !== 'branch'.","triggerScenarios":"Same as 65: renameBranch with an oldName that is null, a tag, a commit, or otherwise not a branch ref.","commonSituations":"Misspelled branch names, renaming tags, passing HEAD.","solutions":["Validate the ref type before calling renameBranch","Correct the branch name","Delete-then-create the branch if the intent was to move a non-branch ref"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var t = engine.resolveID(oldName); if (!t || t.get('type') !== 'branch') return;","typeGuard":"function isBranch(engine, name) { var r = engine.resolveID(name); return !!r && r.get('type') === 'branch'; }","tryCatchPattern":null,"preventionTips":["Validate ref type first","Double-check spelling of branch names"],"tags":["git","branch","rename","ref-validation"],"backgroundTag":"invalid-git-ref","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}