pcottle/learnGitBranching · error · GitError

bad-tag-name

Error message

bad-tag-name

What it means

validateAndMakeTag validates the name via branch-name rules, then rejects the creation if this.refs[id] is already taken (by a tag OR a branch — one flat ref namespace).

Source

Thrown at src/js/git/index.js:752

GitEngine.prototype.validateAndMakeBranch = function(id, target) {
  id = this.validateBranchName(id);
  if (this.doesRefExist(id)) {
    throw new GitError({
      msg: intl.str(
        'bad-branch-name',
        { branch: id }
      )
    });
  }

  return this.makeBranch(id, target);
};

GitEngine.prototype.validateAndMakeTag = function(id, target) {
  id = this.validateBranchName(id);
  if (this.refs[id]) {
    throw new GitError({
      msg: intl.str(
        'bad-tag-name',
        { tag: id }
      )
    });
  }

  this.makeTag(id, target);
};

GitEngine.prototype.makeBranch = function(id, target) {
  if (this.refs[id]) {
    var err = new Error();
    throw new Error('woah already have that ref ' + id + ' ' + err.stack);
  }

  var branch = new Branch({
    target: target,

View on GitHub (pinned to 5b09d0ff96)

Solutions

  1. Pick a new tag name
  2. Remove the existing tag first: `git tag -d <name>`
  3. If it collides with a branch, choose a non-colliding name

Example fix

// before
git tag v1  // v1 exists
// after
git tag v1.1
Defensive patterns

Strategy: validation

Validate before calling

if (!engine.refs[id]) { engine.validateAndMakeTag(id, target); }

Prevention

When it happens

Trigger: `git tag <name>` where <name> already exists as either a tag or a branch.

Common situations: Re-running level solutions that tag twice; tagging with a name equal to an existing branch.

Related errors


AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27). Data as JSON: /api/errors/473da921a1c00e3b. Report an issue: GitHub.