pcottle/learnGitBranching · warning · GitError

git-error-origin-fetch-uptodate

Error message

git-error-origin-fetch-uptodate

What it means

Thrown during fetch when the source branch's starting commit is already present in the target repository's commit set, meaning there is nothing new to fetch. It mirrors git's 'Already up to date.' message.

Source

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

  targetBranch,
  sourceBranch,
  options
) {
  options = options || {};
  sourceBranch = source.resolveID(sourceBranch);

  var targetSet = Graph.getUpstreamSet(target, targetBranch);
  var sourceStartCommit = source.getCommitFromRef(sourceBranch);

  var sourceTree = source.exportTree();
  var sourceStartCommitJSON = sourceTree.commits[sourceStartCommit.get('id')];

  if (targetSet[sourceStartCommitJSON.id]) {
    // either we throw since theres no work to be done, or we return an empty array
    if (options.dontThrowOnNoFetch) {
      return [];
    } else {
      throw new GitError({
        msg: intl.str('git-error-origin-fetch-uptodate')
      });
    }
  }

  // ok great, we have our starting point and our stopping set. lets go ahead
  // and traverse upwards and keep track of depth manually
  sourceStartCommitJSON.depth = 0;
  var difference = [];
  var toExplore = [sourceStartCommitJSON];

  var pushParent = function(parentID) {
    if (targetSet[parentID]) {
      // we already have that commit, lets bounce
      return;
    }

    var parentJSON = sourceTree.commits[parentID];

View on GitHub (pinned to 5b09d0ff96)

Solutions

  1. Treat this as informational — nothing needs fetching; continue your workflow
  2. If scripting automated fetches, pass options.dontThrowOnFetch true (dontThrowOnNoFetch) so an empty array is returned instead
  3. Catch CommandResult/GitError and ignore the up-to-date case

Example fix

// before
this.fetch('origin', 'main'); // throws when up to date
// after
this.fetch('origin', 'main', { dontThrowOnNoFetch: true });
Defensive patterns

Strategy: try-catch

Validate before calling

var targetSet = Graph.getCommitSet(target, targetBranch);
if (targetSet[sourceStart.id]) { /* skip fetch */ }

Try / catch

try { engine.fetch(...); } catch (e) { if (e instanceof GitError && e.msg === intl.str('git-error-origin-fetch-uptodate')) return; throw e; }

Prevention

When it happens

Trigger: Calling fetch where targetSet[sourceStartCommitJSON.id] is truthy and options.dontThrowOnNoFetch is not set — i.e. fetching a remote branch whose head commit you already have.

Common situations: Running fetch twice in a row in a level; scripted tests that fetch without checking state first.

Related errors


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