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
- Prefix the branch with the remote, e.g. o/main
- Run git fetch first so the remote-tracking ref exists
- 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
- Prefix remote branches with o/ in UI hints
- Filter branch lists by getIsRemote() for remote-only commands
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
- cannot fetch to ' + ref + ' when checked out on ' + ref
- ' + ref + ' is not a branch
- ' + generalArgs[0] + ' is not a remote in your repository! t
- ' + branchName + ' is not a branch!
- git-error-origin-required
AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27).
Data as JSON: /api/errors/06c666834a539643.
Report an issue: GitHub.