name: gh-cli description: 'GitHub CLI (gh) comprehensive reference for repositories, issues, pull requests, Actions, releases, and all GitHub operations from the command line. Use when working with GitHub repositories, creating PRs, managing issues, or automating workflows.' source: github/awesome-copilot source_file: skills/gh-cli/SKILL.md source_sha: bc7d1b0750e48d3ae80fcd517f95ac9d1c181474 adopted: 2026-01-29 customizations: Condensed from 40KB original; focused on most common operations license: MIT
GitHub CLI (gh) Skill
Comprehensive reference for GitHub CLI — work seamlessly with GitHub from the command line.
Prerequisites
Installation
# macOS
brew install gh
# Windows
winget install --id GitHub.cli
# Linux (Debian/Ubuntu)
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update && sudo apt install gh
Authentication
# Interactive login
gh auth login
# Check status
gh auth status
# Setup git credential helper
gh auth setup-git
# View token
gh auth token
Repository Operations
Create Repository
# Create new repository
gh repo create my-repo --public --description "My project"
# Create from current directory
gh repo create --source=. --push
# Create private repo in org
gh repo create org/my-repo --private
Clone & Fork
# Clone repository
gh repo clone owner/repo
# Fork repository
gh repo fork owner/repo --clone
# Sync fork with upstream
gh repo sync owner/repo
View Repository
# View repo info
gh repo view
# View in browser
gh browse
# View specific file
gh browse src/index.ts
Issues
Create Issues
# Interactive create
gh issue create
# Create with title and body
gh issue create --title "Bug: login fails" --body "Steps to reproduce..."
# Create with labels and assignee
gh issue create --title "Feature request" --label "enhancement" --assignee "@me"
List & View Issues
# List open issues
gh issue list
# List with filters
gh issue list --state closed --label "bug" --assignee "@me"
# View specific issue
gh issue view 123
# View in browser
gh issue view 123 --web
Manage Issues
# Close issue
gh issue close 123
# Reopen issue
gh issue reopen 123
# Add comment
gh issue comment 123 --body "Working on this"
# Edit issue
gh issue edit 123 --add-label "priority:high"
# Create branch from issue
gh issue develop 123 --checkout
Pull Requests
Create PR
# Interactive create
gh pr create
# Create with details
gh pr create --title "Add feature X" --body "Description..." --base main
# Create draft PR
gh pr create --draft
# Create and request review
gh pr create --reviewer octocat,hubot
List & View PRs
# List open PRs
gh pr list
# List PRs you need to review
gh pr list --search "review-requested:@me"
# View specific PR
gh pr view 456
# View diff
gh pr diff 456
Review & Merge PRs
# Checkout PR locally
gh pr checkout 456
# Review PR
gh pr review 456 --approve
gh pr review 456 --request-changes --body "Please fix..."
gh pr review 456 --comment --body "Looks good overall"
# Merge PR
gh pr merge 456 --squash --delete-branch
# Check PR status
gh pr checks 456
Update PR
# Edit PR
gh pr edit 456 --title "New title" --add-label "ready"
# Mark ready for review
gh pr ready 456
# Update branch with base
gh pr update-branch 456
Actions & Workflows
View Runs
# List workflow runs
gh run list
# View specific run
gh run view 12345
# Watch run in progress
gh run watch 12345
Manage Runs
# Rerun failed jobs
gh run rerun 12345 --failed
# Cancel run
gh run cancel 12345
# Download artifacts
gh run download 12345
Trigger Workflows
# Run workflow
gh workflow run build.yml
# Run with inputs
gh workflow run deploy.yml --field environment=staging
# List workflows
gh workflow list
Search
# Search code
gh search code "useState" --repo owner/repo
# Search issues
gh search issues "bug" --state open --label "priority:high"
# Search PRs
gh search prs "author:@me" --state merged
# Search repos
gh search repos "react typescript" --language TypeScript
API Access
# GET request
gh api repos/owner/repo
# POST request
gh api repos/owner/repo/issues --method POST --field title="New issue"
# With pagination
gh api repos/owner/repo/issues --paginate
# GraphQL query
gh api graphql -f query='{ viewer { login } }'
Configuration
# Set default editor
gh config set editor vim
# Set git protocol
gh config set git_protocol ssh
# List config
gh config list
Environment Variables
export GH_TOKEN=ghp_xxxx # GitHub token
export GH_HOST=github.com # GitHub host
export GH_REPO=owner/repo # Default repository
export GH_PROMPT_DISABLED=true # Disable prompts
Common Workflows
Feature Development
# 1. Create branch from issue
gh issue develop 123 --checkout
# 2. Work on feature...
# 3. Create PR
gh pr create --title "Implement feature #123" --body "Closes #123"
# 4. Request review
gh pr edit --add-reviewer teammate
# 5. After approval, merge
gh pr merge --squash --delete-branch
Code Review
# 1. List PRs to review
gh pr list --search "review-requested:@me"
# 2. Checkout PR
gh pr checkout 456
# 3. Review code locally, run tests
# 4. Submit review
gh pr review 456 --approve --body "LGTM!"
Release
# Create release
gh release create v1.0.0 --title "Version 1.0.0" --notes "Release notes..."
# Create release with assets
gh release create v1.0.0 ./dist/*.zip --title "Version 1.0.0"
# List releases
gh release list
# Download release assets
gh release download v1.0.0
Quick Reference
| Task | Command |
|---|---|
| Clone repo | gh repo clone owner/repo |
| Create issue | gh issue create |
| Create PR | gh pr create |
| Checkout PR | gh pr checkout 123 |
| Merge PR | gh pr merge 123 |
| View in browser | gh browse |
| Run workflow | gh workflow run name.yml |
| Search code | gh search code "query" |
References
- GitHub CLI Documentation
- github/awesome-copilot gh-cli skill