pcottle/learnGitBranching · error · GitError

git-error-origin-exists

Error message

git-error-origin-exists

What it means

makeOrigin creates the simulated origin repository; it refuses to run when origin already exists, because remotes are single in this app (one 'origin').

Source

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

      }, this);
  this.tagCollection.each(function(tag) {
        this.gitVisuals.addTag(tag);
      }, this);

  if (tree.originTree) {
    var treeString = JSON.stringify(tree.originTree);
    // if we don't have an animation queue (like when loading
    // right away), just go ahead and make an empty one
    this.animationQueue = this.animationQueue || new AnimationQueue({
      callback: function() {}
    });
    this.makeOrigin(treeString);
  }
};

GitEngine.prototype.makeOrigin = function(treeString) {
  if (this.hasOrigin()) {
    throw new GitError({
      msg: intl.str('git-error-origin-exists')
    });
  }
  treeString = treeString || this.printTree(this.exportTreeForBranch('main'));

  // this is super super ugly but a necessary hack because of the way LGB was
  // originally designed. We need to get to the top level visualization from
  // the git engine -- aka we need to access our own visuals, then the
  // visualization and ask the main vis to create a new vis/git pair. Then
  // we grab the gitengine out of that and assign that as our origin repo
  // which connects the two. epic
  var mainVis = this.gitVisuals.getVisualization();
  var originVis = mainVis.makeOrigin({
    localRepo: this,
    treeString: treeString
  });

  // defer the starting of our animation until origin has been created

View on GitHub (pinned to 5b09d0ff96)

Solutions

  1. Skip the second clone — origin is already there
  2. Reset/reload the level or sandbox before cloning again
  3. In level code, guard with `if (!engine.hasOrigin())` before makeOrigin

Example fix

// before
git clone
git clone
// after
git clone
git fetch
Defensive patterns

Strategy: validation

Validate before calling

if (!engine.hasOrigin()) { engine.makeOrigin(); }

Prevention

When it happens

Trigger: Calling git clone (or engine.makeOrigin) a second time; some level restarts that re-run clone on an existing remote.

Common situations: Users typing clone twice; level definitions that both clone in their start state and execute a clone command.

Related errors


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