sincecutoff.com
← all changes

gh repo read-file and read-dir inspect repository contents

Introduced 2026-06-17 · score 0.99

HOW TO USE IT

When you need to inspect a GitHub repository without cloning it, use `gh repo read-file` to read a file or save it locally, and `gh repo read-dir` to list directory entries. Both use the default branch unless you pass `--ref`; both commands are in preview.

gh repo read-file <path> --repo <owner>/<repo>
gh repo read-file <path> --repo <owner>/<repo> --ref <branch|tag|commit> --output <local-path>
gh repo read-dir <directory-path> --repo <owner>/<repo>

WHY THIS HELPS

Inspect a repository’s files or directory without cloning it.

REQUIREMENTS AND LIMITATIONS

  • Version: v2.95.0
  • Availability: Preview; subject to change without notice.
  • <path> (required): Repository file path for `read-file`.
  • <directory-path>: Directory to list; omit to list the repository root.
  • --repo <[HOST/]OWNER/REPO>: Select a repository.
  • --ref <branch|tag|commit>: Read or list at the specified branch, tag, or commit; defaults to the repository’s default branch.
  • --output <path>: Write file contents to a local path instead of stdout.
  • --clobber: Overwrite the output path if it already exists.
  • --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: Both commands are in preview and subject to change without notice.
  • Both commands default to the repository’s default branch.
  • `--ref` targets a branch, tag, or commit.

FIRST-PARTY EVIDENCE

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

Report a problem with this card