GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, projects, releases, and all GitHub operations. Use when working with GitHub from command line, managing repos, creating PRs/issues, reviewing code, running Actions, or automating GitHub workflows.
Work seamlessly with GitHub from the command line.
Version: 2.85.0
Clone repos via SSH ([email protected]:...), not HTTPS.
# Authenticate
gh auth login
# Clone and work with repositories
gh repo clone owner/repo
cd repo
# Create and manage PRs
gh pr create --title "Fix bug" --body "Description"
gh pr list
gh pr checkout 123
# Work with issues
gh issue create --title "Bug report" --body "Details"
gh issue list
gh
├── auth # Authentication
├── repo # Repositories
├── pr # Pull Requests
├── issue # Issues
├── run # Workflow runs
├── workflow # Workflows
├── release # Releases
├── project # Projects
├── gist # Gists
├── codespace # Codespaces
├── search # Search
├── api # API requests
└── ...
| Module | Command | Reference |
|---|---|---|
| Authentication | gh auth | references/auth.md |
| Repositories | gh repo | references/repos.md |
| Pull Requests | gh pr | references/prs.md |
| Issues | gh issue | references/issues.md |
| GitHub Actions | gh run, gh workflow | references/actions.md |
| Releases | gh release | references/releases.md |
| Projects | gh project | references/projects.md |
| Gists & Codespaces | gh gist, gh codespace | references/gists.md |
| Other commands | gh label, gh search, etc. | references/misc.md |
Load the relevant reference file when working with specific commands.
# Create branch from issue
gh issue develop 123 --branch feature/issue-123
# Make changes, commit, push
git add .
git commit -m "Fix issue #123"
git push
# Create PR linking to issue
gh pr create --title "Fix #123" --body "Closes #123"
# Create repository with initial setup
gh repo create my-project --public \
--description "My awesome project" \
--clone --gitignore python --license mit
cd my-project
# Set up branch protection (via API)
gh api repos/owner/repo/branches/main/protection \
--method PUT --input protection.json
# Close multiple issues
gh issue list --search "label:stale" \
--json number --jq '.[].number' | \
xargs -I {} gh issue close {} --comment "Closing as stale"
# Add label to multiple PRs
gh pr list --search "review:required" \
--json number --jq '.[].number' | \
xargs -I {} gh pr edit {} --add-label needs-review
# JSON output for scripting
gh pr list --json number,title,author
# Filter with jq
gh pr list --json number,title | jq '.[] | select(.title | contains("fix"))'
# Template output
gh pr view 123 --template '{{.title}} by @{{.author.login}}'
# Quiet mode (for scripts)
gh pr checks --quiet
# Specify repository
gh pr list --repo owner/repo
# Disable prompts
gh pr create --title "Fix" --body "Desc" --fill
# JSON output
gh issue list --json number,title
# Paginate all results
gh repo list --paginate
# Help for any command
gh pr create --help
export GH_HOST=github.com # GitHub hostname
export GH_PROMPT_DISABLED=true # Disable prompts
export GH_PAGER=cat # Disable pager
export GH_DEBUG=api # Debug API requests
--web to open browser for complex operations--json for scripting and automationgh repo set-default to avoid --repo flaggh alias set co "pr checkout"gh browse to quickly open repo, PR, or issue pagesgh --help # General help
gh pr --help # Command help
gh pr create --help # Subcommand help
gh reference # Full reference