{"record":{"id":"7d283c823c6cf6ff","repo":"pcottle/learnGitBranching","slug":"bad-branch-name","errorCode":null,"errorMessage":"bad-branch-name","messagePattern":"bad-branch-name","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/git/index.js","lineNumber":700,"sourceCode":"\nGitEngine.prototype.getDetachedHead = function() {\n  // detached head is if HEAD points to a commit instead of a branch...\n  var target = this.HEAD.get('target');\n  var targetType = target.get('type');\n  return targetType !== 'branch';\n};\n\nGitEngine.prototype.validateBranchName = function(name) {\n  // Lets escape some of the nasty characters\n  name = name.replace(/&#x2F;/g,\"\\/\");\n  name = name.replace(/\\s/g, '');\n  // And then just make sure it starts with alpha-numeric,\n  // can contain a slash or dash, and then ends with alpha\n  if (\n    !/^\\w([.\\/\\-]?\\w+)*$/.test(name) ||\n    name.search('o/') === 0\n  ) {\n    throw new GitError({\n      msg: intl.str(\n        'bad-branch-name',\n        { branch: name }\n      )\n    });\n  }\n  if (/^[cC]\\d+$/.test(name)) {\n    throw new GitError({\n      msg: intl.str(\n        'bad-branch-name',\n        { branch: name }\n      )\n    });\n  }\n  if (/[hH][eE][aA][dD]/.test(name)) {\n    throw new GitError({\n      msg: intl.str(\n        'bad-branch-name',","sourceCodeStart":682,"sourceCodeEnd":718,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/index.js#L682-L718","documentation":"Branch names must match /^(\\w([./-]?\\w+)*)$/ and must not start with 'o/' (reserved for remote-tracking refs). Any other name — spaces, leading dash/slash, trailing punctuation, etc. — throws bad-branch-name.","triggerScenarios":"`git branch <name>` where name contains invalid characters, starts with a symbol, or begins with the o/ prefix.","commonSituations":"Names with spaces unquoted, names starting with '-' (parsed as option), trying to create 'o/main' manually.","solutions":["Use letters/digits separated by single . / - separators, e.g. feature-x or bug/fix1","Wrap names in quotes in the command line to preserve them","Never prefix local branches with o/"],"exampleFix":"// before\ngit branch my feature\n// after\ngit branch my-feature","handlingStrategy":"validation","validationCode":"function isValidBranchName(n){ return /^\\w([.\\/-]?\\w+)*$/.test(n) && n.indexOf('o/') !== 0; }","typeGuard":"function isValidBranchName(n){ return /^\\w([.\\/-]?\\w+)*$/.test(n) && n.indexOf('o/') !== 0; }","tryCatchPattern":null,"preventionTips":["Quote branch names on the command line","Avoid leading dashes/slashes and spaces","Never create o/-prefixed local branches"],"tags":["git","branch","name-validation"],"backgroundTag":"git-invalid-ref-name","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}