Use the `gh` CLI to operate GitHub from the command line, including PRs, Issues, CI runs, and advanced API queries.
Installation
# macOS
brew install gh
# Linux
sudo apt install gh
# Windows
winget install GitHub.cli
Authentication
gh auth login
Common Commands
Pull Requests
# List PRs
gh pr list
# View PR checks
gh pr checks 55 --repo owner/repo
# Create PR
gh pr create --title "Fix bug" --body "Description"
Issues
# List issues
gh issue list
# Create issue
gh issue create --title "Bug report" --body "Details"
# Close issue
gh issue close 123
Workflow Runs
# List workflow runs
gh run list --repo owner/repo --limit 10
# View run details
gh run view <run-id> --repo owner/repo
# View failed logs
gh run view <run-id> --repo owner/repo --log-failed
API Queries
# Get PR details
gh api repos/owner/repo/pulls/55 --jq '.title, .state'
# List repo contents
gh api repos/owner/repo/contents --jq '.[].name'
Quick Reference
| Command | Description |
|---|---|
| gh pr list | List PRs |
| gh pr create | Create PR |
| gh pr checks | View CI status |
| gh issue list | List Issues |
| gh run list | List workflows |
| gh api | API query |