pcottle/learnGitBranching · error · GitError

' + ref + ' is not a remote branch

Error message

' + ref + ' is not a remote branch

What it means

assertIsRemoteBranch throws when the ref resolves but is not a branch with getIsRemote() true — i.e. it isn't a remote-tracking branch like o/main. Used by commands that specifically operate on remote branches.

Source

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

var assertIsBranch = function(engine, ref) {
  assertIsRef(engine, ref);
  var obj = engine.resolveID(ref);
  if (!obj || obj.get('type') !== 'branch') {
    throw new GitError({
      msg: intl.todo(
        ref + ' is not a branch'
      )
    });
  }
};

var assertIsRemoteBranch = function(engine, ref) {
  assertIsRef(engine, ref);
  var obj = engine.resolveID(ref);

  if (obj.get('type') !== 'branch' ||
      !obj.getIsRemote()) {
    throw new GitError({
      msg: intl.todo(
        ref + ' is not a remote branch'
      )
    });
  }
};

var assertOriginSpecified = function(generalArgs) {
  if (!generalArgs.length) {
    return;
  }
  if (generalArgs[0] !== 'origin') {
    throw new GitError({
      msg: intl.todo(
        generalArgs[0] + ' is not a remote in your repository! try adding origin to that argument'
      )
    });
  }

View on GitHub (pinned to 5b09d0ff96)

Solutions

  1. Prefix the branch with the remote, e.g. o/main
  2. Run git fetch first so the remote-tracking ref exists
  3. Check engine.origin.resolveID(ref) before calling

Example fix

// before
git branch -d main --remote
// after
git branch -d o/main --remote  (i.e. target the remote-tracking ref)
Defensive patterns

Strategy: type-guard

Validate before calling

var obj = engine.resolveID(ref); if (!obj || obj.get('type') !== 'branch' || !obj.getIsRemote()) return;

Type guard

function isRemoteBranchRef(engine, ref) { var o = engine.resolveID(ref); return !!o && o.get('type') === 'branch' && !!o.getIsRemote(); }

Prevention

When it happens

Trigger: Passing a local branch ('main') or a tag where a remote branch ('o/main', or 'main' resolved against origin) is required, e.g. git fetch/push configs that call assertIsRemoteBranch on engine.origin refs.

Common situations: Forgetting the o/ prefix in LearnGitBranching remote levels; assuming origin resolution is automatic.

Related errors


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