| name | gh-cli |
| description | GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, gists, codespaces, organizations, extensions, and all GitHub operations from the command line. |
| check_command | gh --version |
GitHub CLI (gh)
Work seamlessly with GitHub from the command line. For the complete command reference see references/full-reference.md.
Authentication
gh auth login
gh auth login --with-token < token.txt
gh auth status
gh auth switch --hostname github.com --user username
gh auth setup-git
gh auth token
Pull Requests
gh pr create
gh pr create --title "Feature: X" --body "Details..." --base main --draft --reviewer alice
gh pr list
gh pr list --author @me --labels bug --state all --limit 50
gh pr view 123
gh pr view 123 --comments --web
gh pr merge 123 --squash --delete-branch
gh pr checks 123
gh pr checks 123 --watch
Issues
gh issue create
gh issue create --title "Bug: X" --body "Steps..." --labels bug,high-priority --assignee @me
gh issue list
gh issue list --assignee @me --labels bug --state all --search "is:open label:bug"
gh issue view 123
gh issue view 123 --comments --web
gh issue close 123 --comment "Fixed in PR #456"
gh issue reopen 123
Common Flags
| Flag | Description |
|---|
--repo OWNER/REPO | Target a specific repository |
--json FIELDS | Output JSON for given fields |
--jq EXPRESSION | Filter JSON output with jq |
--web | Open result in browser |
--paginate | Follow pagination for large result sets |
--limit N | Cap result count |
API Requests
gh api /user --jq '.login'
gh api --method POST /repos/owner/repo/issues \
--field title="Issue title" --field body="Body"
gh api /user/repos --paginate
gh api graphql -f query='{ viewer { login } }'
JSON Output Examples
gh pr list --json number,title --jq '.[] | "\(.number): \(.title)"'
gh issue view 123 --json labels --jq '.labels[].name'
gh pr list --json number,title,author \
--jq '.[] | select(.author.login == "alice")'
Complete Reference
For all commands including repos, releases, Actions, projects, gists, codespaces, search, secrets, extensions, and more, see:
references/full-reference.md