GH-REPO-READ-DIR(1) GitHub CLI manual GH-REPO-READ-DIR(1)

# [NAME](#NAME)

gh-repo-read-dir - List a directory in a repository (preview)

# [SYNOPSIS](#SYNOPSIS)

**gh repo read-dir \[&lt;path&gt;] \[flags]**

# [DESCRIPTION](#DESCRIPTION)

List the contents of a directory in a GitHub repository without cloning it.

This command is in preview and subject to change without notice.

By default, the directory is listed from the default branch. Use the **--ref** flag to list from a specific branch, tag, or commit. When no path is given, the repository root is listed.

# [OPTIONS](#OPTIONS)

[**-q**, **--jq** **&lt;expression&gt;**](#q)

Filter JSON output using a jq expression

[**--json** **&lt;fields&gt;**](#json)

Output JSON with the specified fields

[**--ref** **&lt;string&gt;**](#ref)

The branch, tag, or commit to list from

[**-R**, **--repo** **&lt;\[HOST/\]OWNER/REPO&gt;**](#R)

Select another repository using the \[HOST/]OWNER/REPO format

[**-t**, **--template** **&lt;string&gt;**](#t)

Format JSON output using a Go template; see "gh help formatting"

# [JSON FIELDS](#JSON_FIELDS)

**gitSHA**, **gitType**, **mode**, **modeOctal**, **name**, **nameRaw**, **path**, **pathRaw**, **size**, **submodule**, **type**

# [EXIT CODES](#EXIT_CODES)

0: Successful execution

1: Error

2: Command canceled

4: Authentication required

NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information.

# [EXAMPLE](#EXAMPLE)

```
# List the root of the default branch
$ gh repo read-dir --repo cli/cli
# List a subdirectory
$ gh repo read-dir docs --repo cli/cli
# List a directory at a specific ref
$ gh repo read-dir docs --repo cli/cli --ref v2.50.0
# Print selected fields as JSON
$ gh repo read-dir docs --repo cli/cli --json name,path,type,size
```

# [SEE ALSO](#SEE_ALSO)

[**gh-repo(1)**](/man/os/gh/gh-repo.1)

Oct 2026

---

Document: gh-repo-read-dir(1) from gh 2.103.0-r0 (Chainguard OS)
Source: https://github.com/cli/cli
