sincecutoff.com
← all changes

gh repo read-file and read-dir inspect remote repository content

Introduced 2026-06-17 · score 0.99

HOW TO USE IT

When using GitHub CLI v2.95.0 or later to inspect a remote repository without cloning, run `gh repo read-file <path> --repo <owner>/<repo>` to read a file or `gh repo read-dir [<path>] --repo <owner>/<repo>` to list a directory.

gh repo read-file <path> --repo <owner>/<repo>
gh repo read-dir [<path>] --repo <owner>/<repo>
gh repo read-file <path> --repo <owner>/<repo> --ref <branch|tag|commit>

WHY THIS HELPS

Inspect files or browse directories in a remote repository from your terminal without cloning it.

REQUIREMENTS AND LIMITATIONS

  • Version: v2.95.0 or later
  • Availability: Available to all GitHub users, including those on GitHub Enterprise Server (GHES).
  • Requires Install or upgrade GitHub CLI to v2.95.0 or later.
  • <path> (read-file) (required): Path of the file to read.
  • [<path>] (read-dir): Directory to list; omitted means repository root.
  • --repo <[HOST/]OWNER/REPO> (required): Select the repository to inspect.
  • --ref <string>: Branch, tag, or commit to read or list from; default is the repository’s default branch.
  • --output <path>: For read-file, write the file to a path instead of stdout.
  • --clobber: For read-file, overwrite the output path if it already exists.
  • --allow-escape-sequences: For read-file, allow printing terminal escape sequences.
  • --json <fields>: Output JSON with selected fields.
  • --jq <expression>: Filter JSON output using a jq expression.
  • --template <string>: Format JSON output using a Go template.
  • Prerequisite: Install or upgrade GitHub CLI to v2.95.0 or later for these commands.
  • Prerequisite: Both commands are in preview and may change without notice.
  • The commands allow exploration without cloning.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card