google-gemini/gemini-cli · error · Error

Unable to determine the GitHub repository. /setup-github mus

Error message

Unable to determine the GitHub repository. /setup-github must be run from a git repository.

What it means

Thrown at the start of /setup-github when isGitHubRepository() returns false. That helper runs `git remote -v` and tests for 'github.com'; if git is missing, not a repo, or the remote is not GitHub (GitLab/Bitbucket/etc.), it returns false and this error fires.

Source

Thrown at packages/cli/src/ui/commands/setupGithubCommand.ts:219

        });
      }),
    );
  } catch (error) {
    debugLogger.debug('Failed to download required setup files: ', error);
    throw error;
  }
}

export const setupGithubCommand: SlashCommand = {
  name: 'setup-github',
  description: 'Set up GitHub Actions',
  kind: CommandKind.BUILT_IN,
  autoExecute: true,
  action: async (
    context: CommandContext,
  ): Promise<SlashCommandActionReturn> => {
    if (!isGitHubRepository()) {
      throw new Error(
        'Unable to determine the GitHub repository. /setup-github must be run from a git repository.',
      );
    }

    // Find the root directory of the repo
    let gitRepoRoot: string;
    try {
      gitRepoRoot = getGitRepoRoot();
    } catch (error) {
      debugLogger.debug(`Failed to get git repo root:`, error);
      throw new Error(
        'Unable to determine the GitHub repository. /setup-github must be run from a git repository.',
      );
    }

    // Get the latest release tag from GitHub
    const proxy = context?.services?.agentContext?.config.getProxy();
    const releaseTag = await getLatestGitHubRelease(proxy);

View on GitHub (pinned to 5024443c72)

Solutions

  1. Run /setup-github from inside a git working tree (`git init` if needed).
  2. Ensure the repo has a remote pointing at github.com (verify with `git remote -v`).
  3. Install git and ensure it is on PATH if `git remote -v` currently fails.
  4. If your project is hosted elsewhere, /setup-github is GitHub-specific and not applicable.

Example fix

# before — no remote
mkdir proj && cd proj && git init
gemini  # /setup-github -> error
# after
git remote add origin https://github.com/user/proj.git
gemini  # /setup-github works
Defensive patterns

Strategy: validation

Validate before calling

import { execSync } from 'node:child_process';
function isGithubCwd(): boolean {
  try {
    return /github\.com/.test(execSync('git remote -v', { encoding: 'utf-8' }) || '');
  } catch { return false; }
}
if (!isGithubCwd()) throw new Error('Run /setup-github inside a GitHub git repo');

Type guard

function isGitHubRepository(): boolean {
  try { return /github\.com/.test(execSync('git remote -v', { encoding: 'utf-8' }) || ''); }
  catch { return false; }
}

Try / catch

try {
  await runSetupGithub(ctx);
} catch (e) {
  if (e instanceof Error && /must be run from a git repository/.test(e.message)) {
    // ensure cwd is a git repo with a github.com remote, then retry
  }
  throw e;
}

Prevention

When it happens

Trigger: isGitHubRepository() returns false because: not inside a git repo (git remote -v fails), or the configured remotes do not contain github.com.

Common situations: Running /setup-github outside any git repo; inside a repo whose remote points to a non-GitHub host; a freshly cloned repo where the remote was changed/removed; git not installed so the execSync throws and is caught as false.

Related errors


AI-assisted analysis of google-gemini/gemini-cli@5024443c72 (2026-08-12). Data as JSON: /api/errors/44066fbb1b3799fd. Report an issue: GitHub.