| name | gh-cli |
| description | 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. |
GitHub CLI (gh)
Work seamlessly with GitHub from the command line.
Version: 2.85.0
Preference
Clone repos via SSH (git@github.com:...), not HTTPS.
Quick Start
gh auth login
gh repo clone owner/repo
cd repo
gh pr create --title "Fix bug" --body "Description"
gh pr list
gh pr checkout 123
gh issue create --title "Bug report" --body "Details"
gh issue list
CLI Structure
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 Reference
Load the relevant reference file when working with specific commands.
Common Workflows
Create PR from Issue
gh issue develop 123 --branch feature/issue-123
git add .
git commit -m "Fix issue #123"
git push
gh pr create --title "Fix #123" --body "Closes #123"
Repository Setup
gh repo create my-project --public \
--description "My awesome project" \
--clone --gitignore python --license mit
cd my-project
gh api repos/owner/repo/branches/main/protection \
--method PUT --input protection.json
Bulk Operations
gh issue list --search "label:stale" \
--json number --jq '.[].number' | \
xargs -I {} gh issue close {} --comment "Closing as stale"
gh pr list --search "review:required" \
--json number --jq '.[].number' | \
xargs -I {} gh pr edit {} --add-label needs-review
Output Formatting
gh pr list --json number,title,author
gh pr list --json number,title | jq '.[] | select(.title | contains("fix"))'
gh pr view 123 --template '{{.title}} by @{{.author.login}}'
gh pr checks --quiet
Global Flags
gh pr list --repo owner/repo
gh pr create --title "Fix" --body "Desc" --fill
gh issue list --json number,title
gh repo list --paginate
gh pr create --help
Environment Variables
export GH_HOST=github.com
export GH_PROMPT_DISABLED=true
export GH_PAGER=cat
export GH_DEBUG=api
Best Practices
- Use
--web to open browser for complex operations
- Use
--json for scripting and automation
- Set default repo with
gh repo set-default to avoid --repo flag
- Create aliases for frequently used commands:
gh alias set co "pr checkout"
- Use
gh browse to quickly open repo, PR, or issue pages
Getting Help
gh --help
gh pr --help
gh pr create --help
gh reference
Official Resources