{"record":{"id":"bcadbba091e9ca81","repo":"pcottle/learnGitBranching","slug":"git-error-origin-exists","errorCode":null,"errorMessage":"git-error-origin-exists","messagePattern":"git-error-origin-exists","errorType":"exception","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/git/index.js","lineNumber":387,"sourceCode":"      }, this);\n  this.tagCollection.each(function(tag) {\n        this.gitVisuals.addTag(tag);\n      }, this);\n\n  if (tree.originTree) {\n    var treeString = JSON.stringify(tree.originTree);\n    // if we don't have an animation queue (like when loading\n    // right away), just go ahead and make an empty one\n    this.animationQueue = this.animationQueue || new AnimationQueue({\n      callback: function() {}\n    });\n    this.makeOrigin(treeString);\n  }\n};\n\nGitEngine.prototype.makeOrigin = function(treeString) {\n  if (this.hasOrigin()) {\n    throw new GitError({\n      msg: intl.str('git-error-origin-exists')\n    });\n  }\n  treeString = treeString || this.printTree(this.exportTreeForBranch('main'));\n\n  // this is super super ugly but a necessary hack because of the way LGB was\n  // originally designed. We need to get to the top level visualization from\n  // the git engine -- aka we need to access our own visuals, then the\n  // visualization and ask the main vis to create a new vis/git pair. Then\n  // we grab the gitengine out of that and assign that as our origin repo\n  // which connects the two. epic\n  var mainVis = this.gitVisuals.getVisualization();\n  var originVis = mainVis.makeOrigin({\n    localRepo: this,\n    treeString: treeString\n  });\n\n  // defer the starting of our animation until origin has been created","sourceCodeStart":369,"sourceCodeEnd":405,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/index.js#L369-L405","documentation":"makeOrigin creates the simulated origin repository; it refuses to run when origin already exists, because remotes are single in this app (one 'origin').","triggerScenarios":"Calling git clone (or engine.makeOrigin) a second time; some level restarts that re-run clone on an existing remote.","commonSituations":"Users typing clone twice; level definitions that both clone in their start state and execute a clone command.","solutions":["Skip the second clone — origin is already there","Reset/reload the level or sandbox before cloning again","In level code, guard with `if (!engine.hasOrigin())` before makeOrigin"],"exampleFix":"// before\ngit clone\ngit clone\n// after\ngit clone\ngit fetch","handlingStrategy":"validation","validationCode":"if (!engine.hasOrigin()) { engine.makeOrigin(); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clone exactly once per level/sandbox","Guard level setup code with hasOrigin()","Reload the level instead of re-cloning"],"tags":["git","clone","remote","already-exists"],"backgroundTag":"git-remote-already-exists","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}