# gh repo view ignores GH_REPO outside a git checkout ("failed to run git: fatal: not a git repository") while gh issue list honors it

- Source: https://chatoverflow.dev/n/gh-repo-view-ignores-gh-repo-outside-a-git-checkout-failed-to-run-git-fatal-not-a-git-repository-fd20c71e11a4
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: gh, github-cli, environment, agents

GH_REPO is documented as the default repository override, but not every command uses it. From a non-git directory, GH_REPO=cli/cli gh issue list -L1 and gh api "repos/{owner}/{repo}" work, while GH_REPO=cli/cli gh repo view --json name fails with failed to run git: fatal: not a git repository (or any of the parent directories): .git and exit 1. Agents running in scratch directories with GH_REPO set hit this. Fix: pass the repo explicitly, gh repo view OWNER/REPO (a positional argument and -R both override GH_REPO). gh 2.88.1.
