GH-REPO-READ-DIR(1)
π GH-REPO-READ-DIR(1) β the GitHub CLI manual, bestie edition β¨
okay so this is gh-repo-read-dir, straight out of the GitHub CLI manual (v2.102.0, Oct 2026 β we'll get to that at the end π).
πΈ NAME πΈ
gh-repo-read-dir β list a directory in a repository (preview, babes π)
β¨ SYNOPSIS β¨
gh repo read-dir [<path>] [flags]
π¦ DESCRIPTION π¦
So like⦠you wanna see what's inside a directory in a GitHub repository, but you do not wanna clone the whole thing first? Yeah. That's the entire point of this command. Iconic behavior, honestly.
Heads up bestie: this command is in preview and subject to change without notice. So don't get too attached to the exact shape of things, mwah π
By default, the directory gets listed from the default branch. Wanna peek at a specific branch, tag, or commit? That's what the --ref flag is for, slay. And if you don't give it any path at all? No worries β it just lists the repository root. Easy. π«Ά
π OPTIONS π
-q,--jq <expression>β filter the JSON output using ajqexpression. Yes, the real jq. Go off. π₯--json <fields>β output JSON with the specified fields (pick from the JSON FIELDS list below, iykyk).--ref <string>β the branch, tag, or commit to list from. Time-travel privileges β¨-R,--repo <[HOST/]OWNER/REPO>β select another repository using the[HOST/]OWNER/REPOformat. Like, go look at someone else's repo, respectfully π-t,--template <string>β format the JSON output using a Go template; seegh help formattingfor the deets.
π JSON FIELDS π
Here's the full roster of fields you can ask for, in this exact order:
gitSHA, gitType, mode, modeOctal, name, nameRaw, path, pathRaw, size, submodule, type
π EXIT CODES π
0: Successful execution β we ate π1: Error β it's giving hiccup π2: Command canceled β you hit Ctrl+C, no judgment4: Authentication required β log in first, bestie π
NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information. (read: check the help, there might be more lore π)
β EXAMPLE β
okay here's where it gets fun, look at these:
# 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
Like?? No clone, no fuss, just vibes and directory contents. Main character energy fr fr π β¨
π§ SEE ALSO π§
gh-repo(1)β the whole repo family, go say hi π
and that's the whole page, bestie!! π this was GitHub CLI v2.102.0, dated Oct 2026 β screenshot it, cite it, live your truth. bye ππ¦
π¦ where this page comes from
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms