🛠️

Use GitHub CLI to Read Repo Files Without Cloning

GitHub CLI 2.95.0 adds preview commands for reading files and directories from remote repositories, useful for agents, audits, and quick config checks.

Original
Jun 29, 2026
Status & Access
Current access and latest update details.
Access
Free
Updated
Jun 29, 2026, 11:32 AM

Why this is useful

GitHub CLI 2.95.0 adds gh repo read-file and gh repo read-dir, two preview commands for inspecting repository content directly from the terminal. It is a practical upgrade for developers, maintainers, and AI-agent workflows that need to check a README, config file, package manifest, docs folder, or policy file without cloning the full repository first.

Quick start

# Read a single file from a public or accessible private repository
gh repo read-file README.md --repo cli/cli

# List a directory from a specific ref
gh repo read-dir docs --repo cli/cli --ref v2.95.0

# Return structured data for scripts and agents
gh repo read-dir .github --repo cli/cli --json name,path,type,size

Caveats

The commands are marked preview, so flags or output details may change. Access still follows the permissions of the authenticated GitHub user, and large or binary files are not a replacement for a proper checkout. For automation, pin your expected gh version and handle missing-command fallback paths.

Source check

SourceWhat it confirms
GitHub Changeloggh repo read-file and gh repo read-dir are available in GitHub CLI 2.95.0+
GitHub CLI release notesThe release date, examples, preview status, and scripting flags
GitHub CLI manualExact command syntax, JSON fields, and terminal escape-sequence behavior
Discussion

Sign in to join the discussion and vote on comments.

No comments yet. Start the discussion.
Keep exploring

More from this topic

More in Tools & Apps