pcottle/learnGitBranching · error · GitError

' + branchName + ' is not a remote tracking branch! I don't

Error message

' + branchName + ' is not a remote tracking branch! I don't know where to push

What it means

The branch exists but branch.getRemoteTrackingBranchID() returns null — it has no configured upstream (no o/<name> counterpart). The command (push without explicit refspec) doesn't know where to push.

Source

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

};

var assertBranchIsRemoteTracking = function(engine, branchName) {
  branchName = crappyUnescape(branchName);
  if (!engine.resolveID(branchName)) {
    throw new GitError({
      msg: intl.todo(branchName + ' is not a branch!')
    });
  }
  var branch = engine.resolveID(branchName);
  if (branch.get('type') !== 'branch') {
    throw new GitError({
      msg: intl.todo(branchName + ' is not a branch!')
    });
  }

  var tracking = branch.getRemoteTrackingBranchID();
  if (!tracking) {
    throw new GitError({
      msg: intl.todo(
        branchName + ' is not a remote tracking branch! I don\'t know where to push'
      )
    });
  }
  return tracking;
};

var commandConfig = {
  commit: {
    sc: /^(gc|git ci)($|\s)/,
    regex: /^git +commit($|\s)/,
    description: 'Record changes to the repository',
    options: [
      '--amend',
      '-a',
      '--all',
      '-am',

View on GitHub (pinned to 5b09d0ff96)

Solutions

  1. Push with an explicit refspec: git push origin <branch>
  2. git fetch first so the tracking ref o/<branch> exists
  3. Set the tracking branch (in real git: git push -u origin <branch>)

Example fix

// before
git push
// after
git push origin newbranch
Defensive patterns

Strategy: validation

Validate before calling

var tracking = branch.getRemoteTrackingBranchID(); if (!tracking) { /* push with explicit refspec instead */ }

Type guard

function hasUpstream(branch) { return !!branch.getRemoteTrackingBranchID(); }

Try / catch

try { push(); } catch (e) { if (/remote tracking branch/.test(e.msg)) pushExplicit('origin', branchName); else throw e; }

Prevention

When it happens

Trigger: git push on a locally-created branch that was never fetched/tracked from origin, so no remote-tracking branch exists.

Common situations: Creating a new branch and pushing before setting upstream; classic LearnGitBranching lesson about o/ refs.

Related errors


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