{"id":"github","kind":"sdk","name":"GitHub","slug":"github","description":"Octokit and official GitHub API client libraries.","vendor":"GitHub","languages":["javascript","typescript","nodejs","python","go","ruby","csharp","java"],"categories":["devtools"],"homepage":"https://docs.github.com","docsUrl":"https://docs.github.com/en/rest","githubUrl":"https://github.com/octokit","packages":[{"registry":"npm","name":"@octokit/rest","url":"https://www.npmjs.com/package/@octokit/rest"}],"tags":["git","api"],"skills":[{"name":"gh-cli","url":"https://skills.sh/github/awesome-copilot/gh-cli","install":"npx skills add github/awesome-copilot --skill gh-cli","sdk":"github","key":"github/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.","hasContent":true,"content":"---\nname: gh-cli\ndescription: 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.\n---\n\n# GitHub CLI (gh)\n\nComprehensive reference for GitHub CLI (gh) - work seamlessly with GitHub from the command line.\n\n**Version:** 2.85.0 (current as of January 2026)\n\n## Prerequisites\n\n### Installation\n\n```bash\n# macOS\nbrew install gh\n\n# Linux\ncurl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg\necho \"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\nsudo apt update\nsudo apt install gh\n\n# Windows\nwinget install --id GitHub.cli\n\n# Verify installation\ngh --version\n```\n\n### Authentication\n\n```bash\n# Interactive login (default: github.com)\ngh auth login\n\n# Login with specific hostname\ngh auth login --hostname enterprise.internal\n\n# Login with token\ngh auth login --with-token < mytoken.txt\n\n# Check authentication status\ngh auth status\n\n# Switch accounts\ngh auth switch --hostname github.com --user username\n\n# Logout\ngh auth logout --hostname github.com --user username\n```\n\n### Setup Git Integration\n\n```bash\n# Configure git to use gh as credential helper\ngh auth setup-git\n\n# View active token\ngh auth token\n\n# Refresh authentication scopes\ngh auth refresh --scopes write:org,read:public_key\n```\n\n## CLI Structure\n\n```\ngh                          # Root command\n├── auth                    # Authentication\n│   ├── login\n│   ├── logout\n│   ├── refresh\n│   ├── setup-git\n│   ├── status\n│   ├── switch\n│   └── token\n├── browse                  # Open in browser\n├── codespace               # GitHub Codespaces\n│   ├── code\n│   ├── cp\n│   ├── create\n│   ├── delete\n│   ├── edit\n│   ├── jupyter\n│   ├── list\n│   ├── logs\n│   ├── ports\n│   ├── rebuild\n│   ├── ssh\n│   ├── stop\n│   └── view\n├── gist                    # Gists\n│   ├── clone\n│   ├── create\n│   ├── delete\n│   ├── edit\n│   ├── list\n│   ├── rename\n│   └── view\n├── issue                   # Issues\n│   ├── create\n│   ├── list\n│   ├── status\n│   ├── close\n│   ├── comment\n│   ├── delete\n│   ├── develop\n│   ├── edit\n│   ├── lock\n│   ├── pin\n│   ├── reopen\n│   ├── transfer\n│   ├── unlock\n│   └── view\n├── org                     # Organizations\n│   └── list\n├── pr                      # Pull Requests\n│   ├── create\n│   ├── list\n│   ├── status\n│   ├── checkout\n│   ├── checks\n│   ├── close\n│   ├── comment\n│   ├── diff\n│   ├── edit\n│   ├── lock\n│   ├── merge\n│   ├── ready\n│   ├── reopen\n│   ├── revert\n│   ├── review\n│   ├── unlock\n│   ├── update-branch\n│   └── view\n├── project                 # Projects\n│   ├── close\n│   ├── copy\n│   ├── create\n│   ├── delete\n│   ├── edit\n│   ├── field-create\n│   ├── field-delete\n│   ├── field-list\n│   ├── item-add\n│   ├── item-archive\n│   ├── item-create\n│   ├── item-delete\n│   ├── item-edit\n│   ├── item-list\n│   ├── link\n│   ├── list\n│   ├── mark-template\n│   ├── unlink\n│   └── view\n├── release                 # Releases\n│   ├── create\n│   ├── list\n│   ├── delete\n│   ├── delete-asset\n│   ├── download\n│   ├── edit\n│   ├── upload\n│   ├── verify\n│   ├── verify-asset\n│   └── view\n├── repo                    # Repositories\n│   ├── create\n│   ├── list\n│   ├── archive\n│   ├── autolink\n│   ├── clone\n│   ├── delete\n│   ├── deploy-key\n│   ├── edit\n│   ├── fork\n│   ├── gitignore\n│   ├── license\n│   ├── rename\n│   ├── set-default\n│   ├── sync\n│   ├── unarchive\n│   └── view\n├── cache                   # Actions caches\n│   ├── delete\n│   └── list\n├── run                     # Workflow runs\n│   ├── cancel\n│   ├── delete\n│   ├── download\n│   ├── list\n│   ├── rerun\n│   ├── view\n│   └── watch\n├── workflow                # Workflows\n│   ├── disable\n│   ├── enable\n│   ├── list\n│   ├── run\n│   └── view\n├── agent-task              # Agent tasks\n├── alias                   # Command aliases\n│   ├── delete\n│   ├── import\n│   ├── list\n│   └── set\n├── api                     # API requests\n├── attestation             # Artifact attestations\n│   ├── download\n│   ├── trusted-root\n│   └── verify\n├── completion              # Shell completion\n├── config                  # Configuration\n│   ├── clear-cache\n│   ├── get\n│   ├── list\n│   └── set\n├── extension               # Extensions\n│   ├── browse\n│   ├── create\n│   ├── exec\n│   ├── install\n│   ├── list\n│   ├── remove\n│   ├── search\n│   └── upgrade\n├── gpg-key                 # GPG keys\n│   ├── add\n│   ├── delete\n│   └── list\n├── label                   # Labels\n│   ├── clone\n│   ├── create\n│   ├── delete\n│   ├── edit\n│   └── list\n├── preview                 # Preview features\n├── ruleset                 # Rulesets\n│   ├── check\n│   ├── list\n│   └── view\n├── search                  # Search\n│   ├── code\n│   ├── commits\n│   ├── issues\n│   ├── prs\n│   └── repos\n├── secret                  # Secrets\n│   ├── delete\n│   ├── list\n│   └── set\n├── ssh-key                 # SSH keys\n│   ├── add\n│   ├── delete\n│   └── list\n├── status                  # Status overview\n└── variable                # Variables\n    ├── delete\n    ├── get\n    ├── list\n    └── set\n```\n\n## Configuration\n\n### Global Configuration\n\n```bash\n# List all configuration\ngh config list\n\n# Get specific configuration value\ngh config list git_protocol\ngh config get editor\n\n# Set configuration value\ngh config set editor vim\ngh config set git_protocol ssh\ngh config set prompt disabled\ngh config set pager \"less -R\"\n\n# Clear configuration cache\ngh config clear-cache\n```\n\n### Environment Variables\n\n```bash\n# GitHub token (for automation)\nexport GH_TOKEN=ghp_xxxxxxxxxxxx\n\n# GitHub hostname\nexport GH_HOST=github.com\n\n# Disable prompts\nexport GH_PROMPT_DISABLED=true\n\n# Custom editor\nexport GH_EDITOR=vim\n\n# Custom pager\nexport GH_PAGER=less\n\n# HTTP timeout\nexport GH_TIMEOUT=30\n\n# Custom repository (override default)\nexport GH_REPO=owner/repo\n\n# Custom git protocol\nexport GH_ENTERPRISE_HOSTNAME=hostname\n```\n\n## Authentication (gh auth)\n\n### Login\n\n```bash\n# Interactive login\ngh auth login\n\n# Web-based authentication\ngh auth login --web\n\n# With clipboard for OAuth code\ngh auth login --web --clipboard\n\n# With specific git protocol\ngh auth login --git-protocol ssh\n\n# With custom hostname (GitHub Enterprise)\ngh auth login --hostname enterprise.internal\n\n# Login with token from stdin\ngh auth login --with-token < token.txt\n\n# Insecure storage (plain text)\ngh auth login --insecure-storage\n```\n\n### Status\n\n```bash\n# Show all authentication status\ngh auth status\n\n# Show active account only\ngh auth status --active\n\n# Show specific hostname\ngh auth status --hostname github.com\n\n# Show token in output\ngh auth status --show-token\n\n# JSON output\ngh auth status --json hosts\n\n# Filter with jq\ngh auth status --json hosts --jq '.hosts | add'\n```\n\n### Switch Accounts\n\n```bash\n# Interactive switch\ngh auth switch\n\n# Switch to specific user/host\ngh auth switch --hostname github.com --user monalisa\n```\n\n### Token\n\n```bash\n# Print authentication token\ngh auth token\n\n# Token for specific host/user\ngh auth token --hostname github.com --user monalisa\n```\n\n### Refresh\n\n```bash\n# Refresh credentials\ngh auth refresh\n\n# Add scopes\ngh auth refresh --scopes write:org,read:public_key\n\n# Remove scopes\ngh auth refresh --remove-scopes delete_repo\n\n# Reset to default scopes\ngh auth refresh --reset-scopes\n\n# With clipboard\ngh auth refresh --clipboard\n```\n\n### Setup Git\n\n```bash\n# Setup git credential helper\ngh auth setup-git\n\n# Setup for specific host\ngh auth setup-git --hostname enterprise.internal\n\n# Force setup even if host not known\ngh auth setup-git --hostname enterprise.internal --force\n```\n\n## Browse (gh browse)\n\n```bash\n# Open repository in browser\ngh browse\n\n# Open specific path\ngh browse script/\ngh browse main.go:312\n\n# Open issue or PR\ngh browse 123\n\n# Open commit\ngh browse 77507cd94ccafcf568f8560cfecde965fcfa63\n\n# Open with specific branch\ngh browse main.go --branch bug-fix\n\n# Open different repository\ngh browse --repo owner/repo\n\n# Open specific pages\ngh browse --actions       # Actions tab\ngh browse --projects      # Projects tab\ngh browse --releases      # Releases tab\ngh browse --settings      # Settings page\ngh browse --wiki          # Wiki page\n\n# Print URL instead of opening\ngh browse --no-browser\n```\n\n## Repositories (gh repo)\n\n### Create Repository\n\n```bash\n# Create new repository\ngh repo create my-repo\n\n# Create with description\ngh repo create my-repo --description \"My awesome project\"\n\n# Create public repository\ngh repo create my-repo --public\n\n# Create private repository\ngh repo create my-repo --private\n\n# Create with homepage\ngh repo create my-repo --homepage https://example.com\n\n# Create with license\ngh repo create my-repo --license mit\n\n# Create with gitignore\ngh repo create my-repo --gitignore python\n\n# Initialize as template repository\ngh repo create my-repo --template\n\n# Create repository in organization\ngh repo create org/my-repo\n\n# Create without cloning locally\ngh repo create my-repo --source=.\n\n# Disable issues\ngh repo create my-repo --disable-issues\n\n# Disable wiki\ngh repo create my-repo --disable-wiki\n```\n\n### Clone Repository\n\n```bash\n# Clone repository\ngh repo clone owner/repo\n\n# Clone to specific directory\ngh repo clone owner/repo my-directory\n\n# Clone with different branch\ngh repo clone owner/repo --branch develop\n```\n\n### List Repositories\n\n```bash\n# List all repositories\ngh repo list\n\n# List repositories for owner\ngh repo list owner\n\n# Limit results\ngh repo list --limit 50\n\n# Public repositories only\ngh repo list --public\n\n# Source repositories only (not forks)\ngh repo list --source\n\n# JSON output\ngh repo list --json name,visibility,owner\n\n# Table output\ngh repo list --limit 100 | tail -n +2\n\n# Filter with jq\ngh repo list --json name --jq '.[].name'\n```\n\n### View Repository\n\n```bash\n# View repository details\ngh repo view\n\n# View specific repository\ngh repo view owner/repo\n\n# JSON output\ngh repo view --json name,description,defaultBranchRef\n\n# View in browser\ngh repo view --web\n```\n\n### Edit Repository\n\n```bash\n# Edit description\ngh repo edit --description \"New description\"\n\n# Set homepage\ngh repo edit --homepage https://example.com\n\n# Change visibility\ngh repo edit --visibility private\ngh repo edit --visibility public\n\n# Enable/disable features\ngh repo edit --enable-issues\ngh repo edit --disable-issues\ngh repo edit --enable-wiki\ngh repo edit --disable-wiki\ngh repo edit --enable-projects\ngh repo edit --disable-projects\n\n# Set default branch\ngh repo edit --default-branch main\n\n# Rename repository\ngh repo rename new-name\n\n# Archive repository\ngh repo archive\ngh repo unarchive\n```\n\n### Delete Repository\n\n```bash\n# Delete repository\ngh repo delete owner/repo\n\n# Confirm without prompt\ngh repo delete owner/repo --yes\n```\n\n### Fork Repository\n\n```bash\n# Fork repository\ngh repo fork owner/repo\n\n# Fork to organization\ngh repo fork owner/repo --org org-name\n\n# Clone after forking\ngh repo fork owner/repo --clone\n\n# Remote name for fork\ngh repo fork owner/repo --remote-name upstream\n```\n\n### Sync Fork\n\n```bash\n# Sync fork with upstream\ngh repo sync\n\n# Sync specific branch\ngh repo sync --branch feature\n\n# Force sync\ngh repo sync --force\n```\n\n### Set Default Repository\n\n```bash\n# Set default repository for current directory\ngh repo set-default\n\n# Set default explicitly\ngh repo set-default owner/repo\n\n# Unset default\ngh repo set-default --unset\n```\n\n### Repository Autolinks\n\n```bash\n# List autolinks\ngh repo autolink list\n\n# Add autolink\ngh repo autolink add \\\n  --key-prefix JIRA- \\\n  --url-template https://jira.example.com/browse/<num>\n\n# Delete autolink\ngh repo autolink delete 12345\n```\n\n### Repository Deploy Keys\n\n```bash\n# List deploy keys\ngh repo deploy-key list\n\n# Add deploy key\ngh repo deploy-key add ~/.ssh/id_rsa.pub \\\n  --title \"Production server\" \\\n  --read-only\n\n# Delete deploy key\ngh repo deploy-key delete 12345\n```\n\n### Gitignore and License\n\n```bash\n# View gitignore template\ngh repo gitignore\n\n# View license template\ngh repo license mit\n\n# License with full name\ngh repo license mit --fullname \"John Doe\"\n```\n\n## Issues (gh issue)\n\n### Create Issue\n\n```bash\n# Create issue interactively\ngh issue create\n\n# Create with title\ngh issue create --title \"Bug: Login not working\"\n\n# Create with title and body\ngh issue create \\\n  --title \"Bug: Login not working\" \\\n  --body \"Steps to reproduce...\"\n\n# Create with body from file\ngh issue create --body-file issue.md\n\n# Create with labels\ngh issue create --title \"Fix bug\" --labels bug,high-priority\n\n# Create with assignees\ngh issue create --title \"Fix bug\" --assignee user1,user2\n\n# Create in specific repository\ngh issue create --repo owner/repo --title \"Issue title\"\n\n# Create issue from web\ngh issue create --web\n```\n\n### List Issues\n\n```bash\n# List all open issues\ngh issue list\n\n# List all issues (including closed)\ngh issue list --state all\n\n# List closed issues\ngh issue list --state closed\n\n# Limit results\ngh issue list --limit 50\n\n# Filter by assignee\ngh issue list --assignee username\ngh issue list --assignee @me\n\n# Filter by labels\ngh issue list --labels bug,enhancement\n\n# Filter by milestone\ngh issue list --milestone \"v1.0\"\n\n# Search/filter\ngh issue list --search \"is:open is:issue label:bug\"\n\n# JSON output\ngh issue list --json number,title,state,author\n\n# Table view\ngh issue list --json number,title,labels --jq '.[] | [.number, .title, .labels[].name] | @tsv'\n\n# Show comments count\ngh issue list --json number,title,comments --jq '.[] | [.number, .title, .comments]'\n\n# Sort by\ngh issue list --sort created --order desc\n```\n\n### View Issue\n\n```bash\n# View issue\ngh issue view 123\n\n# View with comments\ngh issue view 123 --comments\n\n# View in browser\ngh issue view 123 --web\n\n# JSON output\ngh issue view 123 --json title,body,state,labels,comments\n\n# View specific fields\ngh issue view 123 --json title --jq '.title'\n```\n\n### Edit Issue\n\n```bash\n# Edit interactively\ngh issue edit 123\n\n# Edit title\ngh issue edit 123 --title \"New title\"\n\n# Edit body\ngh issue edit 123 --body \"New description\"\n\n# Add labels\ngh issue edit 123 --add-label bug,high-priority\n\n# Remove labels\ngh issue edit 123 --remove-label stale\n\n# Add assignees\ngh issue edit 123 --add-assignee user1,user2\n\n# Remove assignees\ngh issue edit 123 --remove-assignee user1\n\n# Set milestone\ngh issue edit 123 --milestone \"v1.0\"\n```\n\n### Close/Reopen Issue\n\n```bash\n# Close issue\ngh issue close 123\n\n# Close with comment\ngh issue close 123 --comment \"Fixed in PR #456\"\n\n# Reopen issue\ngh issue reopen 123\n```\n\n### Comment on Issue\n\n```bash\n# Add comment\ngh issue comment 123 --body \"This looks good!\"\n\n# Edit comment\ngh issue comment 123 --edit 456789 --body \"Updated comment\"\n\n# Delete comment\ngh issue comment 123 --delete 456789\n```\n\n### Issue Status\n\n```bash\n# Show issue status summary\ngh issue status\n\n# Status for specific repository\ngh issue status --repo owner/repo\n```\n\n### Pin/Unpin Issues\n\n```bash\n# Pin issue (pinned to repo dashboard)\ngh issue pin 123\n\n# Unpin issue\ngh issue unpin 123\n```\n\n### Lock/Unlock Issue\n\n```bash\n# Lock conversation\ngh issue lock 123\n\n# Lock with reason\ngh issue lock 123 --reason off-topic\n\n# Unlock\ngh issue unlock 123\n```\n\n### Transfer Issue\n\n```bash\n# Transfer to another repository\ngh issue transfer 123 --repo owner/new-repo\n```\n\n### Delete Issue\n\n```bash\n# Delete issue\ngh issue delete 123\n\n# Confirm without prompt\ngh issue delete 123 --yes\n```\n\n### Develop Issue (Draft PR)\n\n```bash\n# Create draft PR from issue\ngh issue develop 123\n\n# Create in specific branch\ngh issue develop 123 --branch fix/issue-123\n\n# Create with base branch\ngh issue develop 123 --base main\n```\n\n## Pull Requests (gh pr)\n\n### Create Pull Request\n\n```bash\n# Create PR interactively\ngh pr create\n\n# Create with title\ngh pr create --title \"Feature: Add new functionality\"\n\n# Create with title and body\ngh pr create \\\n  --title \"Feature: Add new functionality\" \\\n  --body \"This PR adds...\"\n\n# Fill body from template\ngh pr create --body-file .github/PULL_REQUEST_TEMPLATE.md\n\n# Set base branch\ngh pr create --base main\n\n# Set head branch (default: current branch)\ngh pr create --head feature-branch\n\n# Create draft PR\ngh pr create --draft\n\n# Add assignees\ngh pr create --assignee user1,user2\n\n# Add reviewers\ngh pr create --reviewer user1,user2\n\n# Add labels\ngh pr create --labels enhancement,feature\n\n# Link to issue\ngh pr create --issue 123\n\n# Create in specific repository\ngh pr create --repo owner/repo\n\n# Open in browser after creation\ngh pr create --web\n```\n\n### List Pull Requests\n\n```bash\n# List open PRs\ngh pr list\n\n# List all PRs\ngh pr list --state all\n\n# List merged PRs\ngh pr list --state merged\n\n# List closed (not merged) PRs\ngh pr list --state closed\n\n# Filter by head branch\ngh pr list --head feature-branch\n\n# Filter by base branch\ngh pr list --base main\n\n# Filter by author\ngh pr list --author username\ngh pr list --author @me\n\n# Filter by assignee\ngh pr list --assignee username\n\n# Filter by labels\ngh pr list --labels bug,enhancement\n\n# Limit results\ngh pr list --limit 50\n\n# Search\ngh pr list --search \"is:open is:pr label:review-required\"\n\n# JSON output\ngh pr list --json number,title,state,author,headRefName\n\n# Show check status\ngh pr list --json number,title,statusCheckRollup --jq '.[] | [.number, .title, .statusCheckRollup[]?.status]'\n\n# Sort by\ngh pr list --sort created --order desc\n```\n\n### View Pull Request\n\n```bash\n# View PR\ngh pr view 123\n\n# View with comments\ngh pr view 123 --comments\n\n# View in browser\ngh pr view 123 --web\n\n# JSON output\ngh pr view 123 --json title,body,state,author,commits,files\n\n# View diff\ngh pr view 123 --json files --jq '.files[].path'\n\n# View with jq query\ngh pr view 123 --json title,state --jq '\"\\(.title): \\(.state)\"'\n```\n\n### Checkout Pull Request\n\n```bash\n# Checkout PR branch\ngh pr checkout 123\n\n# Checkout with specific branch name\ngh pr checkout 123 --branch name-123\n\n# Force checkout\ngh pr checkout 123 --force\n```\n\n### Diff Pull Request\n\n```bash\n# View PR diff\ngh pr diff 123\n\n# View diff with color\ngh pr diff 123 --color always\n\n# Output to file\ngh pr diff 123 > pr-123.patch\n\n# View diff of specific files\ngh pr diff 123 --name-only\n```\n\n### Merge Pull Request\n\n```bash\n# Merge PR\ngh pr merge 123\n\n# Merge with specific method\ngh pr merge 123 --merge\ngh pr merge 123 --squash\ngh pr merge 123 --rebase\n\n# Delete branch after merge\ngh pr merge 123 --delete-branch\n\n# Merge with comment\ngh pr merge 123 --subject \"Merge PR #123\" --body \"Merging feature\"\n\n# Merge draft PR\ngh pr merge 123 --admin\n\n# Force merge (skip checks)\ngh pr merge 123 --admin\n```\n\n### Close Pull Request\n\n```bash\n# Close PR (as draft, not merge)\ngh pr close 123\n\n# Close with comment\ngh pr close 123 --comment \"Closing due to...\"\n```\n\n### Reopen Pull Request\n\n```bash\n# Reopen closed PR\ngh pr reopen 123\n```\n\n### Edit Pull Request\n\n```bash\n# Edit interactively\ngh pr edit 123\n\n# Edit title\ngh pr edit 123 --title \"New title\"\n\n# Edit body\ngh pr edit 123 --body \"New description\"\n\n# Add labels\ngh pr edit 123 --add-label bug,enhancement\n\n# Remove labels\ngh pr edit 123 --remove-label stale\n\n# Add assignees\ngh pr edit 123 --add-assignee user1,user2\n\n# Remove assignees\ngh pr edit 123 --remove-assignee user1\n\n# Add reviewers\ngh pr edit 123 --add-reviewer user1,user2\n\n# Remove reviewers\ngh pr edit 123 --remove-reviewer user1\n\n# Mark as ready for review\ngh pr edit 123 --ready\n```\n\n### Ready for Review\n\n```bash\n# Mark draft PR as ready\ngh pr ready 123\n```\n\n### Pull Request Checks\n\n```bash\n# View PR checks\ngh pr checks 123\n\n# Watch checks in real-time\ngh pr checks 123 --watch\n\n# Watch interval (seconds)\ngh pr checks 123 --watch --interval 5\n```\n\n### Comment on Pull Request\n\n```bash\n# Add comment\ngh pr comment 123 --body \"Looks good!\"\n\n# Comment on specific line\ngh pr comment 123 --body \"Fix this\" \\\n  --repo owner/repo \\\n  --head-owner owner --head-branch feature\n\n# Edit comment\ngh pr comment 123 --edit 456789 --body \"Updated\"\n\n# Delete comment\ngh pr comment 123 --delete 456789\n```\n\n### Review Pull Request\n\n```bash\n# Review PR (opens editor)\ngh pr review 123\n\n# Approve PR\ngh pr review 123 --approve --body \"LGTM!\"\n\n# Request changes\ngh pr review 123 --request-changes \\\n  --body \"Please fix these issues\"\n\n# Comment on PR\ngh pr review 123 --comment --body \"Some thoughts...\"\n\n# Dismiss review\ngh pr review 123 --dismiss\n```\n\n### Update Branch\n\n```bash\n# Update PR branch with latest base branch\ngh pr update-branch 123\n\n# Force update\ngh pr update-branch 123 --force\n\n# Use merge strategy\ngh pr update-branch 123 --merge\n```\n\n### Lock/Unlock Pull Request\n\n```bash\n# Lock PR conversation\ngh pr lock 123\n\n# Lock with reason\ngh pr lock 123 --reason off-topic\n\n# Unlock\ngh pr unlock 123\n```\n\n### Revert Pull Request\n\n```bash\n# Revert merged PR\ngh pr revert 123\n\n# Revert with specific branch name\ngh pr revert 123 --branch revert-pr-123\n```\n\n### Pull Request Status\n\n```bash\n# Show PR status summary\ngh pr status\n\n# Status for specific repository\ngh pr status --repo owner/repo\n```\n\n## GitHub Actions\n\n### Workflow Runs (gh run)\n\n```bash\n# List workflow runs\ngh run list\n\n# List for specific workflow\ngh run list --workflow \"ci.yml\"\n\n# List for specific branch\ngh run list --branch main\n\n# Limit results\ngh run list --limit 20\n\n# JSON output\ngh run list --json databaseId,status,conclusion,headBranch\n\n# View run details\ngh run view 123456789\n\n# View run with verbose logs\ngh run view 123456789 --log\n\n# View specific job\ngh run view 123456789 --job 987654321\n\n# View in browser\ngh run view 123456789 --web\n\n# Watch run in real-time\ngh run watch 123456789\n\n# Watch with interval\ngh run watch 123456789 --interval 5\n\n# Rerun failed run\ngh run rerun 123456789\n\n# Rerun specific job\ngh run rerun 123456789 --job 987654321\n\n# Cancel run\ngh run cancel 123456789\n\n# Delete run\ngh run delete 123456789\n\n# Download run artifacts\ngh run download 123456789\n\n# Download specific artifact\ngh run download 123456789 --name build\n\n# Download to directory\ngh run download 123456789 --dir ./artifacts\n```\n\n### Workflows (gh workflow)\n\n```bash\n# List workflows\ngh workflow list\n\n# View workflow details\ngh workflow view ci.yml\n\n# View workflow YAML\ngh workflow view ci.yml --yaml\n\n# View in browser\ngh workflow view ci.yml --web\n\n# Enable workflow\ngh workflow enable ci.yml\n\n# Disable workflow\ngh workflow disable ci.yml\n\n# Run workflow manually\ngh workflow run ci.yml\n\n# Run with inputs\ngh workflow run ci.yml \\\n  --raw-field \\\n  version=\"1.0.0\" \\\n  environment=\"production\"\n\n# Run from specific branch\ngh workflow run ci.yml --ref develop\n```\n\n### Action Caches (gh cache)\n\n```bash\n# List caches\ngh cache list\n\n# List for specific branch\ngh cache list --branch main\n\n# List with limit\ngh cache list --limit 50\n\n# Delete cache\ngh cache delete 123456789\n\n# Delete all caches\ngh cache delete --all\n```\n\n### Action Secrets (gh secret)\n\n```bash\n# List secrets\ngh secret list\n\n# Set secret (prompts for value)\ngh secret set MY_SECRET\n\n# Set secret from environment\necho \"$MY_SECRET\" | gh secret set MY_SECRET\n\n# Set secret for specific environment\ngh secret set MY_SECRET --env production\n\n# Set secret for organization\ngh secret set MY_SECRET --org orgname\n\n# Delete secret\ngh secret delete MY_SECRET\n\n# Delete from environment\ngh secret delete MY_SECRET --env production\n```\n\n### Action Variables (gh variable)\n\n```bash\n# List variables\ngh variable list\n\n# Set variable\ngh variable set MY_VAR \"some-value\"\n\n# Set variable for environment\ngh variable set MY_VAR \"value\" --env production\n\n# Set variable for organization\ngh variable set MY_VAR \"value\" --org orgname\n\n# Get variable value\ngh variable get MY_VAR\n\n# Delete variable\ngh variable delete MY_VAR\n\n# Delete from environment\ngh variable delete MY_VAR --env production\n```\n\n## Projects (gh project)\n\n```bash\n# List projects\ngh project list\n\n# List for owner\ngh project list --owner owner\n\n# Open projects\ngh project list --open\n\n# View project\ngh project view 123\n\n# View project items\ngh project view 123 --format json\n\n# Create project\ngh project create --title \"My Project\"\n\n# Create in organization\ngh project create --title \"Project\" --org orgname\n\n# Create with readme\ngh project create --title \"Project\" --readme \"Description here\"\n\n# Edit project\ngh project edit 123 --title \"New Title\"\n\n# Delete project\ngh project delete 123\n\n# Close project\ngh project close 123\n\n# Copy project\ngh project copy 123 --owner target-owner --title \"Copy\"\n\n# Mark template\ngh project mark-template 123\n\n# List fields\ngh project field-list 123\n\n# Create field\ngh project field-create 123 --title \"Status\" --datatype single_select\n\n# Delete field\ngh project field-delete 123 --id 456\n\n# List items\ngh project item-list 123\n\n# Create item\ngh project item-create 123 --title \"New item\"\n\n# Add item to project\ngh project item-add 123 --owner-owner --repo repo --issue 456\n\n# Edit item\ngh project item-edit 123 --id 456 --title \"Updated title\"\n\n# Delete item\ngh project item-delete 123 --id 456\n\n# Archive item\ngh project item-archive 123 --id 456\n\n# Link items\ngh project link 123 --id 456 --link-id 789\n\n# Unlink items\ngh project unlink 123 --id 456 --link-id 789\n\n# View project in browser\ngh project view 123 --web\n```\n\n## Releases (gh release)\n\n```bash\n# List releases\ngh release list\n\n# View latest release\ngh release view\n\n# View specific release\ngh release view v1.0.0\n\n# View in browser\ngh release view v1.0.0 --web\n\n# Create release\ngh release create v1.0.0 \\\n  --notes \"Release notes here\"\n\n# Create release with notes from file\ngh release create v1.0.0 --notes-file notes.md\n\n# Create release with target\ngh release create v1.0.0 --target main\n\n# Create release as draft\ngh release create v1.0.0 --draft\n\n# Create pre-release\ngh release create v1.0.0 --prerelease\n\n# Create release with title\ngh release create v1.0.0 --title \"Version 1.0.0\"\n\n# Upload asset to release\ngh release upload v1.0.0 ./file.tar.gz\n\n# Upload multiple assets\ngh release upload v1.0.0 ./file1.tar.gz ./file2.tar.gz\n\n# Upload with label (casing sensitive)\ngh release upload v1.0.0 ./file.tar.gz --casing\n\n# Delete release\ngh release delete v1.0.0\n\n# Delete with cleanup tag\ngh release delete v1.0.0 --yes\n\n# Delete specific asset\ngh release delete-asset v1.0.0 file.tar.gz\n\n# Download release assets\ngh release download v1.0.0\n\n# Download specific asset\ngh release download v1.0.0 --pattern \"*.tar.gz\"\n\n# Download to directory\ngh release download v1.0.0 --dir ./downloads\n\n# Download archive (zip/tar)\ngh release download v1.0.0 --archive zip\n\n# Edit release\ngh release edit v1.0.0 --notes \"Updated notes\"\n\n# Verify release signature\ngh release verify v1.0.0\n\n# Verify specific asset\ngh release verify-asset v1.0.0 file.tar.gz\n```\n\n## Gists (gh gist)\n\n```bash\n# List gists\ngh gist list\n\n# List all gists (including private)\ngh gist list --public\n\n# Limit results\ngh gist list --limit 20\n\n# View gist\ngh gist view abc123\n\n# View gist files\ngh gist view abc123 --files\n\n# Create gist\ngh gist create script.py\n\n# Create gist with description\ngh gist create script.py --desc \"My script\"\n\n# Create public gist\ngh gist create script.py --public\n\n# Create multi-file gist\ngh gist create file1.py file2.py\n\n# Create from stdin\necho \"print('hello')\" | gh gist create\n\n# Edit gist\ngh gist edit abc123\n\n# Delete gist\ngh gist delete abc123\n\n# Rename gist file\ngh gist rename abc123 --filename old.py new.py\n\n# Clone gist\ngh gist clone abc123\n\n# Clone to directory\ngh gist clone abc123 my-directory\n```\n\n## Codespaces (gh codespace)\n\n```bash\n# List codespaces\ngh codespace list\n\n# Create codespace\ngh codespace create\n\n# Create with specific repository\ngh codespace create --repo owner/repo\n\n# Create with branch\ngh codespace create --branch develop\n\n# Create with specific machine\ngh codespace create --machine premiumLinux\n\n# View codespace details\ngh codespace view\n\n# SSH into codespace\ngh codespace ssh\n\n# SSH with specific command\ngh codespace ssh --command \"cd /workspaces && ls\"\n\n# Open codespace in browser\ngh codespace code\n\n# Open in VS Code\ngh codespace code --codec\n\n# Open with specific path\ngh codespace code --path /workspaces/repo\n\n# Stop codespace\ngh codespace stop\n\n# Delete codespace\ngh codespace delete\n\n# View logs\ngh codespace logs\n\n--tail 100\n\n# View ports\ngh codespace ports\n\n# Forward port\ngh codespace cp 8080:8080\n\n# Rebuild codespace\ngh codespace rebuild\n\n# Edit codespace\ngh codespace edit --machine standardLinux\n\n# Jupyter support\ngh codespace jupyter\n\n# Copy files to/from codespace\ngh codespace cp file.txt :/workspaces/file.txt\ngh codespace cp :/workspaces/file.txt ./file.txt\n```\n\n## Organizations (gh org)\n\n```bash\n# List organizations\ngh org list\n\n# List for user\ngh org list --user username\n\n# JSON output\ngh org list --json login,name,description\n\n# View organization\ngh org view orgname\n\n# View organization members\ngh org view orgname --json members --jq '.members[] | .login'\n```\n\n## Search (gh search)\n\n```bash\n# Search code\ngh search code \"TODO\"\n\n# Search in specific repository\ngh search code \"TODO\" --repo owner/repo\n\n# Search commits\ngh search commits \"fix bug\"\n\n# Search issues\ngh search issues \"label:bug state:open\"\n\n# Search PRs\ngh search prs \"is:open is:pr review:required\"\n\n# Search repositories\ngh search repos \"stars:>1000 language:python\"\n\n# Limit results\ngh search repos \"topic:api\" --limit 50\n\n# JSON output\ngh search repos \"stars:>100\" --json name,description,stargazers\n\n# Order results\ngh search repos \"language:rust\" --order desc --sort stars\n\n# Search with extensions\ngh search code \"import\" --extension py\n\n# Web search (open in browser)\ngh search prs \"is:open\" --web\n```\n\n## Labels (gh label)\n\n```bash\n# List labels\ngh label list\n\n# Create label\ngh label create bug --color \"d73a4a\" --description \"Something isn't working\"\n\n# Create with hex color\ngh label create enhancement --color \"#a2eeef\"\n\n# Edit label\ngh label edit bug --name \"bug-report\" --color \"ff0000\"\n\n# Delete label\ngh label delete bug\n\n# Clone labels from repository\ngh label clone owner/repo\n\n# Clone to specific repository\ngh label clone owner/repo --repo target/repo\n```\n\n## SSH Keys (gh ssh-key)\n\n```bash\n# List SSH keys\ngh ssh-key list\n\n# Add SSH key\ngh ssh-key add ~/.ssh/id_rsa.pub --title \"My laptop\"\n\n# Add key with type\ngh ssh-key add ~/.ssh/id_ed25519.pub --type \"authentication\"\n\n# Delete SSH key\ngh ssh-key delete 12345\n\n# Delete by title\ngh ssh-key delete --title \"My laptop\"\n```\n\n## GPG Keys (gh gpg-key)\n\n```bash\n# List GPG keys\ngh gpg-key list\n\n# Add GPG key\ngh gpg-key add ~/.ssh/id_rsa.pub\n\n# Delete GPG key\ngh gpg-key delete 12345\n\n# Delete by key ID\ngh gpg-key delete ABCD1234\n```\n\n## Status (gh status)\n\n```bash\n# Show status overview\ngh status\n\n# Status for specific repositories\ngh status --repo owner/repo\n\n# JSON output\ngh status --json\n```\n\n## Configuration (gh config)\n\n```bash\n# List all config\ngh config list\n\n# Get specific value\ngh config get editor\n\n# Set value\ngh config set editor vim\n\n# Set git protocol\ngh config set git_protocol ssh\n\n# Clear cache\ngh config clear-cache\n\n# Set prompt behavior\ngh config set prompt disabled\ngh config set prompt enabled\n```\n\n## Extensions (gh extension)\n\n```bash\n# List installed extensions\ngh extension list\n\n# Search extensions\ngh extension search github\n\n# Install extension\ngh extension install owner/extension-repo\n\n# Install from branch\ngh extension install owner/extension-repo --branch develop\n\n# Upgrade extension\ngh extension upgrade extension-name\n\n# Remove extension\ngh extension remove extension-name\n\n# Create new extension\ngh extension create my-extension\n\n# Browse extensions\ngh extension browse\n\n# Execute extension command\ngh extension exec my-extension --arg value\n```\n\n## Aliases (gh alias)\n\n```bash\n# List aliases\ngh alias list\n\n# Set alias\ngh alias set prview 'pr view --web'\n\n# Set shell alias\ngh alias set co 'pr checkout' --shell\n\n# Delete alias\ngh alias delete prview\n\n# Import aliases\ngh alias import ./aliases.sh\n```\n\n## API Requests (gh api)\n\n```bash\n# Make API request\ngh api /user\n\n# Request with method\ngh api --method POST /repos/owner/repo/issues \\\n  --field title=\"Issue title\" \\\n  --field body=\"Issue body\"\n\n# Request with headers\ngh api /user \\\n  --header \"Accept: application/vnd.github.v3+json\"\n\n# Request with pagination\ngh api /user/repos --paginate\n\n# Raw output (no formatting)\ngh api /user --raw\n\n# Include headers in output\ngh api /user --include\n\n# Silent mode (no progress output)\ngh api /user --silent\n\n# Input from file\ngh api --input request.json\n\n# jq query on response\ngh api /user --jq '.login'\n\n# Field from response\ngh api /repos/owner/repo --jq '.stargazers_count'\n\n# GitHub Enterprise\ngh api /user --hostname enterprise.internal\n\n# GraphQL query\ngh api graphql \\\n  -f query='\n  {\n    viewer {\n      login\n      repositories(first: 5) {\n        nodes {\n          name\n        }\n      }\n    }\n  }'\n```\n\n## Rulesets (gh ruleset)\n\n```bash\n# List rulesets\ngh ruleset list\n\n# View ruleset\ngh ruleset view 123\n\n# Check ruleset\ngh ruleset check --branch feature\n\n# Check specific repository\ngh ruleset check --repo owner/repo --branch main\n```\n\n## Attestations (gh attestation)\n\n```bash\n# Download attestation\ngh attestation download owner/repo \\\n  --artifact-id 123456\n\n# Verify attestation\ngh attestation verify owner/repo\n\n# Get trusted root\ngh attestation trusted-root\n```\n\n## Completion (gh completion)\n\n```bash\n# Generate shell completion\ngh completion -s bash > ~/.gh-complete.bash\ngh completion -s zsh > ~/.gh-complete.zsh\ngh completion -s fish > ~/.gh-complete.fish\ngh completion -s powershell > ~/.gh-complete.ps1\n\n# Shell-specific instructions\ngh completion --shell=bash\ngh completion --shell=zsh\n```\n\n## Preview (gh preview)\n\n```bash\n# List preview features\ngh preview\n\n# Run preview script\ngh preview prompter\n```\n\n## Agent Tasks (gh agent-task)\n\n```bash\n# List agent tasks\ngh agent-task list\n\n# View agent task\ngh agent-task view 123\n\n# Create agent task\ngh agent-task create --description \"My task\"\n```\n\n## Global Flags\n\n| Flag                       | Description                            |\n| -------------------------- | -------------------------------------- |\n| `--help` / `-h`            | Show help for command                  |\n| `--version`                | Show gh version                        |\n| `--repo [HOST/]OWNER/REPO` | Select another repository              |\n| `--hostname HOST`          | GitHub hostname                        |\n| `--jq EXPRESSION`          | Filter JSON output                     |\n| `--json FIELDS`            | Output JSON with specified fields      |\n| `--template STRING`        | Format JSON using Go template          |\n| `--web`                    | Open in browser                        |\n| `--paginate`               | Make additional API calls              |\n| `--verbose`                | Show verbose output                    |\n| `--debug`                  | Show debug output                      |\n| `--timeout SECONDS`        | Maximum API request duration           |\n| `--cache CACHE`            | Cache control (default, force, bypass) |\n\n## Output Formatting\n\n### JSON Output\n\n```bash\n# Basic JSON\ngh repo view --json name,description\n\n# Nested fields\ngh repo view --json owner,name --jq '.owner.login + \"/\" + .name'\n\n# Array operations\ngh pr list --json number,title --jq '.[] | select(.number > 100)'\n\n# Complex queries\ngh issue list --json number,title,labels \\\n  --jq '.[] | {number, title: .title, tags: [.labels[].name]}'\n```\n\n### Template Output\n\n```bash\n# Custom template\ngh repo view \\\n  --template '{{.name}}: {{.description}}'\n\n# Multiline template\ngh pr view 123 \\\n  --template 'Title: {{.title}}\nAuthor: {{.author.login}}\nState: {{.state}}\n'\n```\n\n## Common Workflows\n\n### Create PR from Issue\n\n```bash\n# Create branch from issue\ngh issue develop 123 --branch feature/issue-123\n\n# Make changes, commit, push\ngit add .\ngit commit -m \"Fix issue #123\"\ngit push\n\n# Create PR linking to issue\ngh pr create --title \"Fix #123\" --body \"Closes #123\"\n```\n\n### Bulk Operations\n\n```bash\n# Close multiple issues\ngh issue list --search \"label:stale\" \\\n  --json number \\\n  --jq '.[].number' | \\\n  xargs -I {} gh issue close {} --comment \"Closing as stale\"\n\n# Add label to multiple PRs\ngh pr list --search \"review:required\" \\\n  --json number \\\n  --jq '.[].number' | \\\n  xargs -I {} gh pr edit {} --add-label needs-review\n```\n\n### Repository Setup Workflow\n\n```bash\n# Create repository with initial setup\ngh repo create my-project --public \\\n  --description \"My awesome project\" \\\n  --clone \\\n  --gitignore python \\\n  --license mit\n\ncd my-project\n\n# Set up branches\ngit checkout -b develop\ngit push -u origin develop\n\n# Create labels\ngh label create bug --color \"d73a4a\" --description \"Bug report\"\ngh label create enhancement --color \"a2eeef\" --description \"Feature request\"\ngh label create documentation --color \"0075ca\" --description \"Documentation\"\n```\n\n### CI/CD Workflow\n\n```bash\n# Run workflow and wait\nRUN_ID=$(gh workflow run ci.yml --ref main --jq '.databaseId')\n\n# Watch the run\ngh run watch \"$RUN_ID\"\n\n# Download artifacts on completion\ngh run download \"$RUN_ID\" --dir ./artifacts\n```\n\n### Fork Sync Workflow\n\n```bash\n# Fork repository\ngh repo fork original/repo --clone\n\ncd repo\n\n# Add upstream remote\ngit remote add upstream https://github.com/original/repo.git\n\n# Sync fork\ngh repo sync\n\n# Or manual sync\ngit fetch upstream\ngit checkout main\ngit merge upstream/main\ngit push origin main\n```\n\n## Environment Setup\n\n### Shell Integration\n\n```bash\n# Add to ~/.bashrc or ~/.zshrc\neval \"$(gh completion -s bash)\"  # or zsh/fish\n\n# Create useful aliases\nalias gs='gh status'\nalias gpr='gh pr view --web'\nalias gir='gh issue view --web'\nalias gco='gh pr checkout'\n```\n\n### Git Configuration\n\n```bash\n# Use gh as credential helper\ngh auth setup-git\n\n# Set gh as default for repo operations\ngit config --global credential.helper 'gh !gh auth setup-git'\n\n# Or manually\ngit config --global credential.helper github\n```\n\n## Best Practices\n\n1. **Authentication**: Use environment variables for automation\n\n   ```bash\n   export GH_TOKEN=$(gh auth token)\n   ```\n\n2. **Default Repository**: Set default to avoid repetition\n\n   ```bash\n   gh repo set-default owner/repo\n   ```\n\n3. **JSON Parsing**: Use jq for complex data extraction\n\n   ```bash\n   gh pr list --json number,title --jq '.[] | select(.title | contains(\"fix\"))'\n   ```\n\n4. **Pagination**: Use --paginate for large result sets\n\n   ```bash\n   gh issue list --state all --paginate\n   ```\n\n5. **Caching**: Use cache control for frequently accessed data\n   ```bash\n   gh api /user --cache force\n   ```\n\n## Getting Help\n\n```bash\n# General help\ngh --help\n\n# Command help\ngh pr --help\ngh issue create --help\n\n# Help topics\ngh help formatting\ngh help environment\ngh help exit-codes\ngh help accessibility\n```\n\n## References\n\n- Official Manual: https://cli.github.com/manual/\n- GitHub Docs: https://docs.github.com/en/github-cli\n- REST API: https://docs.github.com/en/rest\n- GraphQL API: https://docs.github.com/en/graphql\n","contentSource":"skills.sh/api/download/github/awesome-copilot/gh-cli","contentFetchedAt":"2026-07-27T08:59:33.487Z"}],"featured":true,"official":true,"generatedAt":"2026-07-27T09:02:29.956Z"}