{"record":{"id":"dfa543bf802acc34","repo":"pcottle/learnGitBranching","slug":"ref-is-not-a-branch","errorCode":null,"errorMessage":"' + ref + ' is not a branch","messagePattern":"' \\+ ref \\+ ' is not a branch","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/git/commands.js","lineNumber":65,"sourceCode":"\nvar assertNotCheckedOut = function(engine, ref) {\n  if (!engine.refs[ref]) {\n    return;\n  }\n  if (engine.HEAD.get('target') === engine.refs[ref]) {\n    throw new GitError({\n      msg: intl.todo(\n        'cannot fetch to ' + ref + ' when checked out on ' + ref\n      )\n    });\n  }\n};\n\nvar assertIsBranch = function(engine, ref) {\n  assertIsRef(engine, ref);\n  var obj = engine.resolveID(ref);\n  if (!obj || obj.get('type') !== 'branch') {\n    throw new GitError({\n      msg: intl.todo(\n        ref + ' is not a branch'\n      )\n    });\n  }\n};\n\nvar assertIsRemoteBranch = function(engine, ref) {\n  assertIsRef(engine, ref);\n  var obj = engine.resolveID(ref);\n\n  if (obj.get('type') !== 'branch' ||\n      !obj.getIsRemote()) {\n    throw new GitError({\n      msg: intl.todo(\n        ref + ' is not a remote branch'\n      )\n    });","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/commands.js#L47-L83","documentation":"assertIsBranch resolves the ref via engine.resolveID and throws if the object is missing or its type is not 'branch'. It means the command requires a local branch name but got a tag, commit SHA, remote-tracking ref, or nonexistent name.","triggerScenarios":"Commands whose config calls assertIsBranch, e.g. pushing/fetching with 'v1' (a tag) or 'o/main' or a raw commit id as the branch argument.","commonSituations":"Typo'd branch names; assuming remote-tracking branches (o/main) count as branches; passing tags where branches are required.","solutions":["Verify the name with git branch / engine.getBranches()","Drop the o/ prefix or use the local branch name","If a tag was intended, use a command/option that accepts tags"],"exampleFix":"// before\ngit push origin o/main\n// after\ngit push origin main","handlingStrategy":"type-guard","validationCode":"var obj = engine.resolveID(ref); if (!obj || obj.get('type') !== 'branch') return;","typeGuard":"function isBranchRef(engine, ref) { var o = engine.resolveID(ref); return !!o && o.get('type') === 'branch'; }","tryCatchPattern":null,"preventionTips":["Offer only engine branch names in autocomplete","Resolve and type-check refs before building commands"],"tags":["git","branch","validation"],"backgroundTag":"not-a-branch","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}