browseDownload binary →
gh/GitHub CLI
GitHub (Microsoft)GitHub's official CLI for managing repositories, pull requests, issues, and GitHub Actions.
CI/CD & Source ControlJSON
01Install
brew install gh02Agent Notes
GitHub CLI follows `gh <entity> <action>` pattern: `gh pr create`, `gh issue list`, `gh repo clone`. For machine-readable output, use `--json <field1,field2>` which outputs JSON with only the requested fields. Combine with `--jq` for inline filtering: `gh pr list --json number,title --jq '.[].title'`. Use `gh api` for direct GitHub API access: `gh api repos/{owner}/{repo}/pulls`. Auth tokens in GH_TOKEN env var skip interactive login. For CI, `gh auth status` checks current auth. `gh auth token` prints the token.
03Help Output
Work seamlessly with GitHub from the command line.
USAGE
gh <command> <subcommand> [flags]
CORE COMMANDS
auth: Authenticate gh and git with GitHub
browse: Open repositories, issues, pull requests, and more in the browser
codespace: Connect to and manage codespaces
gist: Manage gists
issue: Manage issues
org: Manage organizations
pr: Manage pull requests
project: Work with GitHub Projects.
release: Manage releases
repo: Manage repositories
GITHUB ACTIONS COMMANDS
cache: Manage GitHub Actions caches
run: View details about workflow runs
workflow: View details about GitHub Actions workflows
EXTENSION COMMANDS
aw: Extension aw
ALIAS COMMANDS
co: Alias for "pr checkout"
ADDITIONAL COMMANDS
alias: Create command shortcuts
api: Make an authenticated GitHub API request
attestation: Work with artifact attestations
completion: Generate shell completion scripts
config: Manage configuration for gh
extension: Manage gh extensions
gpg-key: Manage GPG keys
label: Manage labels
preview: Execute previews for gh features
ruleset: View info about repo rulesets
search: Search for repositories, issues, and pull requests
secret: Manage GitHub secrets
ssh-key: Manage SSH keys
status: Print information about relevant issues, pull requests, and notifications across repositories
variable: Manage GitHub Actions variables
HELP TOPICS
accessibility: Learn about GitHub CLI's accessibility experiences
actions: Learn about working with GitHub Actions
environment: Environment variables that can be used with gh
exit-codes: Exit codes used by gh
formatting: Formatting options for JSON data exported from gh
mintty: Information about using gh with MinTTY
reference: A comprehensive reference of all gh commands
FLAGS
--help Show help for command
--version Show gh version
EXAMPLES
$ gh issue create
$ gh repo clone cli/cli
$ gh pr checkout 321
LEARN MORE
Use `gh <command> <subcommand> --help` for more information about a command.
Read the manual at https://cli.github.com/manual
Learn about exit codes using `gh help exit-codes`
Learn about accessibility experiences using `gh help accessibility`
04Global Flags
| Flag | Type | Description |
|---|---|---|
--repo | string | Repository in OWNER/REPO format |
--jq | string | JQ expression to filter JSON output |
--template | string | Go template for output formatting |
05Authentication
Methods
access-tokenoauthenvironment-variables
Env vars
GH_TOKENGITHUB_TOKENGH_ENTERPRISE_TOKENConfig files
~/.config/gh/hosts.ymlSetup
gh auth login06Capabilities
Reference
binary
ghcheck
gh --versionauth
access-token, oauth, environment-variablesformats
text, json, templatejson flag
--json <fields>version
2.88.1