pcottle/learnGitBranching · error · GitError

git-error-origin-required

Error message

git-error-origin-required

What it means

A remote command (pull with --rebase options shown) requires the origin remote to exist in the simulation; engine.hasOrigin() is false so git-error-origin-required is thrown.

Source

Thrown at src/js/git/commands.js:259

  gc: {
    displayName: 'gc',
    regex: /^git +gc($|\s)/,
    description: 'Cleanup unnecessary files and optimize the repository',
    execute: function(engine, command) {
      engine.pruneTree(false);
    }
  },

  pull: {
    regex: /^git +pull($|\s)/,
    description: 'Fetch from and integrate with another repository or branch',
    options: [
      '--force',
      '--rebase'
    ],
    execute: function(engine, command) {
      if (!engine.hasOrigin()) {
        throw new GitError({
          msg: intl.str('git-error-origin-required')
        });
      }

      var commandOptions = command.getOptionsMap();
      var force = !!commandOptions['--force'];
      var generalArgs = command.getGeneralArgs();
      if (commandOptions['--rebase']) {
        generalArgs = commandOptions['--rebase'].concat(generalArgs);
      }
      command.twoArgsForOrigin(generalArgs);
      assertOriginSpecified(generalArgs);
      // here is the deal -- git pull is pretty complex with
      // the arguments it wants. You can
      //   A) specify the remote branch you want to
      //      merge & fetch, in which case it completely
      //      ignores the properties of branch you are on, or
      //

View on GitHub (pinned to 5b09d0ff96)

Solutions

  1. Use a level or setup that creates origin (git clone / level defineCombinations)
  2. Initialize the remote before invoking pull/push/fetch commands
  3. Check engine.hasOrigin() in scripts before remote ops

Example fix

// before
// fresh sandbox
git pull
// after
// level with origin (or git clone)
git clone . origin  (conceptually) then git pull
Defensive patterns

Strategy: validation

Validate before calling

if (!engine.hasOrigin()) { showHint('This level has no remote'); return; }

Type guard

function hasRemote(engine) { return engine.hasOrigin(); }

Prevention

When it happens

Trigger: Running git pull (or a command whose execute begins with the hasOrigin check) in a level/sandbox where no origin repository was set up.

Common situations: Starting remote-level exercises before origin exists; custom levels missing the origin definition; testing on a fresh GitEngine.

Related errors


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