Skip to main content

gh-cli

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.

Jump to install

Source facts

Repository
forgivesam168/ai-dev-workflow
Last source activity
February 9, 2026 at 07:21
Detected SKILL.md language
English
Stars
2
Forks
1

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

Showing SKILL.md

SKILL.md
Source instructions ยท Read-only preview
name
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.
# GitHub CLI (gh) Comprehensive reference for GitHub CLI (gh) - work seamlessly with GitHub from the command line. **Version:** 2.85.0 (current as of January 2026) ## Prerequisites ### Installation ```bash # macOS brew install gh # Linux 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 # Windows winget install --id GitHub.cli # Verify installation gh --version ``` ### Authentication ```bash # Interactive login (default: github.com) gh auth login # Login with specific hostname gh auth login --hostname enterprise.internal # Login with token gh auth login --with-token < mytoken.txt # Check authentication status gh auth status # Switch accounts gh auth switch --hostname github.com --user username # Logout gh auth logout --hostname github.com --user username ``` ### Setup Git Integration ```bash # Configure git to use gh as credential helper gh auth setup-git # View active token gh auth token # Refresh authentication scopes gh auth refresh --scopes write:org,read:public_key ``` ## CLI Structure ``` gh # Root command โ”œโ”€โ”€ auth # Authentication โ”‚ โ”œโ”€โ”€ login โ”‚ โ”œโ”€โ”€ logout โ”‚ โ”œโ”€โ”€ refresh โ”‚ โ”œโ”€โ”€ setup-git โ”‚ โ”œโ”€โ”€ status โ”‚ โ”œโ”€โ”€ switch โ”‚ โ””โ”€โ”€ token โ”œโ”€โ”€ browse # Open in browser โ”œโ”€โ”€ codespace # GitHub Codespaces โ”‚ โ”œโ”€โ”€ code โ”‚ โ”œโ”€โ”€ cp โ”‚ โ”œโ”€โ”€ create โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ edit โ”‚ โ”œโ”€โ”€ jupyter โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ logs โ”‚ โ”œโ”€โ”€ ports โ”‚ โ”œโ”€โ”€ rebuild โ”‚ โ”œโ”€โ”€ ssh โ”‚ โ”œโ”€โ”€ stop โ”‚ โ””โ”€โ”€ view โ”œโ”€โ”€ gist # Gists โ”‚ โ”œโ”€โ”€ clone โ”‚ โ”œโ”€โ”€ create โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ edit โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ rename โ”‚ โ””โ”€โ”€ view โ”œโ”€โ”€ issue # Issues โ”‚ โ”œโ”€โ”€ create โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ status โ”‚ โ”œโ”€โ”€ close โ”‚ โ”œโ”€โ”€ comment โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ develop โ”‚ โ”œโ”€โ”€ edit โ”‚ โ”œโ”€โ”€ lock โ”‚ โ”œโ”€โ”€ pin โ”‚ โ”œโ”€โ”€ reopen โ”‚ โ”œโ”€โ”€ transfer โ”‚ โ”œโ”€โ”€ unlock โ”‚ โ””โ”€โ”€ view โ”œโ”€โ”€ org # Organizations โ”‚ โ””โ”€โ”€ list โ”œโ”€โ”€ pr # Pull Requests โ”‚ โ”œโ”€โ”€ create โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ status โ”‚ โ”œโ”€โ”€ checkout โ”‚ โ”œโ”€โ”€ checks โ”‚ โ”œโ”€โ”€ close โ”‚ โ”œโ”€โ”€ comment โ”‚ โ”œโ”€โ”€ diff โ”‚ โ”œโ”€โ”€ edit โ”‚ โ”œโ”€โ”€ lock โ”‚ โ”œโ”€โ”€ merge โ”‚ โ”œโ”€โ”€ ready โ”‚ โ”œโ”€โ”€ reopen โ”‚ โ”œโ”€โ”€ revert โ”‚ โ”œโ”€โ”€ review โ”‚ โ”œโ”€โ”€ unlock โ”‚ โ”œโ”€โ”€ update-branch โ”‚ โ””โ”€โ”€ view โ”œโ”€โ”€ project # Projects โ”‚ โ”œโ”€โ”€ close โ”‚ โ”œโ”€โ”€ copy โ”‚ โ”œโ”€โ”€ create โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ edit โ”‚ โ”œโ”€โ”€ field-create โ”‚ โ”œโ”€โ”€ field-delete โ”‚ โ”œโ”€โ”€ field-list โ”‚ โ”œโ”€โ”€ item-add โ”‚ โ”œโ”€โ”€ item-archive โ”‚ โ”œโ”€โ”€ item-create โ”‚ โ”œโ”€โ”€ item-delete โ”‚ โ”œโ”€โ”€ item-edit โ”‚ โ”œโ”€โ”€ item-list โ”‚ โ”œโ”€โ”€ link โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ mark-template โ”‚ โ”œโ”€โ”€ unlink โ”‚ โ””โ”€โ”€ view โ”œโ”€โ”€ release # Releases โ”‚ โ”œโ”€โ”€ create โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ delete-asset โ”‚ โ”œโ”€โ”€ download โ”‚ โ”œโ”€โ”€ edit โ”‚ โ”œโ”€โ”€ upload โ”‚ โ”œโ”€โ”€ verify โ”‚ โ”œโ”€โ”€ verify-asset โ”‚ โ””โ”€โ”€ view โ”œโ”€โ”€ repo # Repositories โ”‚ โ”œโ”€โ”€ create โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ archive โ”‚ โ”œโ”€โ”€ autolink โ”‚ โ”œโ”€โ”€ clone โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ deploy-key โ”‚ โ”œโ”€โ”€ edit โ”‚ โ”œโ”€โ”€ fork โ”‚ โ”œโ”€โ”€ gitignore โ”‚ โ”œโ”€โ”€ license โ”‚ โ”œโ”€โ”€ rename โ”‚ โ”œโ”€โ”€ set-default โ”‚ โ”œโ”€โ”€ sync โ”‚ โ”œโ”€โ”€ unarchive โ”‚ โ””โ”€โ”€ view โ”œโ”€โ”€ cache # Actions caches โ”‚ โ”œโ”€โ”€ delete โ”‚ โ””โ”€โ”€ list โ”œโ”€โ”€ run # Workflow runs โ”‚ โ”œโ”€โ”€ cancel โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ download โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ rerun โ”‚ โ”œโ”€โ”€ view โ”‚ โ””โ”€โ”€ watch โ”œโ”€โ”€ workflow # Workflows โ”‚ โ”œโ”€โ”€ disable โ”‚ โ”œโ”€โ”€ enable โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ run โ”‚ โ””โ”€โ”€ view โ”œโ”€โ”€ agent-task # Agent tasks โ”œโ”€โ”€ alias # Command aliases โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ import โ”‚ โ”œโ”€โ”€ list โ”‚ โ””โ”€โ”€ set โ”œโ”€โ”€ api # API requests โ”œโ”€โ”€ attestation # Artifact attestations โ”‚ โ”œโ”€โ”€ download โ”‚ โ”œโ”€โ”€ trusted-root โ”‚ โ””โ”€โ”€ verify โ”œโ”€โ”€ completion # Shell completion โ”œโ”€โ”€ config # Configuration โ”‚ โ”œโ”€โ”€ clear-cache โ”‚ โ”œโ”€โ”€ get โ”‚ โ”œโ”€โ”€ list โ”‚ โ””โ”€โ”€ set โ”œโ”€โ”€ extension # Extensions โ”‚ โ”œโ”€โ”€ browse โ”‚ โ”œโ”€โ”€ create โ”‚ โ”œโ”€โ”€ exec โ”‚ โ”œโ”€โ”€ install โ”‚ โ”œโ”€โ”€ list โ”‚ โ”œโ”€โ”€ remove โ”‚ โ”œโ”€โ”€ search โ”‚ โ””โ”€โ”€ upgrade โ”œโ”€โ”€ gpg-key # GPG keys โ”‚ โ”œโ”€โ”€ add โ”‚ โ”œโ”€โ”€ delete โ”‚ โ””โ”€โ”€ list โ”œโ”€โ”€ label # Labels โ”‚ โ”œโ”€โ”€ clone โ”‚ โ”œโ”€โ”€ create โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ edit โ”‚ โ””โ”€โ”€ list โ”œโ”€โ”€ preview # Preview features โ”œโ”€โ”€ ruleset # Rulesets โ”‚ โ”œโ”€โ”€ check โ”‚ โ”œโ”€โ”€ list โ”‚ โ””โ”€โ”€ view โ”œโ”€โ”€ search # Search โ”‚ โ”œโ”€โ”€ code โ”‚ โ”œโ”€โ”€ commits โ”‚ โ”œโ”€โ”€ issues โ”‚ โ”œโ”€โ”€ prs โ”‚ โ””โ”€โ”€ repos โ”œโ”€โ”€ secret # Secrets โ”‚ โ”œโ”€โ”€ delete โ”‚ โ”œโ”€โ”€ list โ”‚ โ””โ”€โ”€ set โ”œโ”€โ”€ ssh-key # SSH keys โ”‚ โ”œโ”€โ”€ add โ”‚ โ”œโ”€โ”€ delete โ”‚ โ””โ”€โ”€ list โ”œโ”€โ”€ status # Status overview โ””โ”€โ”€ variable # Variables โ”œโ”€โ”€ delete โ”œโ”€โ”€ get โ”œโ”€โ”€ list โ””โ”€โ”€ set ``` ## Configuration ### Global Configuration ```bash # List all configuration gh config list # Get specific configuration value gh config list git_protocol gh config get editor # Set configuration value gh config set editor vim gh config set git_protocol ssh gh config set prompt disabled gh config set pager "less -R" # Clear configuration cache gh config clear-cache ``` ### Environment Variables ```bash # GitHub token (for automation) export GH_TOKEN=<YOUR_GITHUB_TOKEN> # ่ซ‹ๆ›ฟๆ›็‚บไฝ ็š„ๅฏฆ้š› token๏ผŒๅˆ‡ๅ‹ฟๆไบคๅˆฐ็‰ˆๆŽง # GitHub hostname export GH_HOST=github.com # Disable prompts export GH_PROMPT_DISABLED=true # Custom editor export GH_EDITOR=vim # Custom pager export GH_PAGER=less # HTTP timeout export GH_TIMEOUT=30 # Custom repository (override default) export GH_REPO=owner/repo # Custom git protocol export GH_ENTERPRISE_HOSTNAME=hostname ``` ## Authentication (gh auth) ### Login ```bash # Interactive login gh auth login # Web-based authentication gh auth login --web # With clipboard for OAuth code gh auth login --web --clipboard # With specific git protocol gh auth login --git-protocol ssh # With custom hostname (GitHub Enterprise) gh auth login --hostname enterprise.internal # Login with token from stdin gh auth login --with-token < token.txt # Insecure storage (plain text) gh auth login --insecure-storage ``` ### Status ```bash # Show all authentication status gh auth status # Show active account only gh auth status --active # Show specific hostname gh auth status --hostname github.com # Show token in output gh auth status --show-token # JSON output gh auth status --json hosts # Filter with jq gh auth status --json hosts --jq '.hosts | add' ``` ### Switch Accounts ```bash # Interactive switch gh auth switch # Switch to specific user/host gh auth switch --hostname github.com --user monalisa ``` ### Token ```bash # Print authentication token gh auth token # Token for specific host/user gh auth token --hostname github.com --user monalisa ``` ### Refresh ```bash # Refresh credentials gh auth refresh # Add scopes gh auth refresh --scopes write:org,read:public_key # Remove scopes gh auth refresh --remove-scopes delete_repo # Reset to default scopes gh auth refresh --reset-scopes # With clipboard gh auth refresh --clipboard ``` ### Setup Git ```bash # Setup git credential helper gh auth setup-git # Setup for specific host gh auth setup-git --hostname enterprise.internal # Force setup even if host not known gh auth setup-git --hostname enterprise.internal --force ``` ## Browse (gh browse) ```bash # Open repository in browser gh browse # Open specific path gh browse script/ gh browse main.go:312 # Open issue or PR gh browse 123 # Open commit gh browse 77507cd94ccafcf568f8560cfecde965fcfa63 # Open with specific branch gh browse main.go --branch bug-fix # Open different repository gh browse --repo owner/repo # Open specific pages gh browse --actions # Actions tab gh browse --projects # Projects tab gh browse --releases # Releases tab gh browse --settings # Settings page gh browse --wiki # Wiki page # Print URL instead of opening gh browse --no-browser ``` ## Repositories (gh repo) ### Create Repository ```bash # Create new repository gh repo create my-repo # Create with description gh repo create my-repo --description "My awesome project" # Create public repository gh repo create my-repo --public # Create private repository gh repo create my-repo --private # Create with homepage gh repo create my-repo --homepage https://example.com # Create with license gh repo create my-repo --license mit # Create with gitignore gh repo create my-repo --gitignore python # Initialize as template repository gh repo create my-repo --template # Create repository in organization gh repo create org/my-repo # Create without cloning locally gh repo create my-repo --source=. # Disable issues gh repo create my-repo --disable-issues # Disable wiki gh repo create my-repo --disable-wiki ``` ### Clone Repository ```bash # Clone repository gh repo clone owner/repo # Clone to specific directory gh repo clone owner/repo my-directory # Clone with different branch gh repo clone owner/repo --branch develop ``` ### List Repositories ```bash # List all repositories gh repo list # List repositories for owner gh repo list owner # Limit results gh repo list --limit 50 # Public repositories only gh repo list --public # Source repositories only (not forks) gh repo list --source # JSON output gh repo list --json name,visibility,owner # Table output gh repo list --limit 100 | tail -n +2 # Filter with jq gh repo list --json name --jq '.[].name' ``` ### View Repository ```bash # View repository details gh repo view # View specific repository gh repo view owner/repo # JSON output gh repo view --json name,description,defaultBranchRef # View in browser gh repo view --web ``` ### Edit Repository ```bash # Edit description gh repo edit --description "New description" # Set homepage gh repo edit --homepage https://example.com # Change visibility gh repo edit --visibility private gh repo edit --visibility public # Enable/disable features gh repo edit --enable-issues gh repo edit --disable-issues gh repo edit --enable-wiki gh repo edit --disable-wiki gh repo edit --enable-projects gh repo edit --disable-projects # Set default branch gh repo edit --default-branch main # Rename repository gh repo rename new-name # Archive repository gh repo archive gh repo unarchive ``` ### Delete Repository ```bash # Delete repository gh repo delete owner/repo # Confirm without prompt gh repo delete owner/repo --yes ``` ### Fork Repository ```bash # Fork repository gh repo fork owner/repo # Fork to organization gh repo fork owner/repo --org org-name # Clone after forking gh repo fork owner/repo --clone # Remote name for fork gh repo fork owner/repo --remote-name upstream ``` ### Sync Fork ```bash # Sync fork with upstream gh repo sync # Sync specific branch gh repo sync --branch feature # Force sync gh repo sync --force ``` ### Set Default Repository ```bash # Set default repository for current directory gh repo set-default # Set default explicitly gh repo set-default owner/repo # Unset default gh repo set-default --unset ``` ### Repository Autolinks ```bash # List autolinks gh repo autolink list # Add autolink gh repo autolink add \ --key-prefix JIRA- \ --url-template https://jira.example.com/browse/<num> # Delete autolink gh repo autolink delete 12345 ``` ### Repository Deploy Keys ```bash # List deploy keys gh repo deploy-key list # Add deploy key gh repo deploy-key add ~/.ssh/id_rsa.pub \ --title "Production server" \ --read-only # Delete deploy key gh repo deploy-key delete 12345 ``` ### Gitignore and License ```bash # View gitignore template gh repo gitignore # View license template gh repo license mit # License with full name gh repo license mit --fullname "John Doe" ``` ## Issues (gh issue) ### Create Issue ```bash # Create issue interactively gh issue create # Create with title gh issue create --title "Bug: Login not working" # Create with title and body gh issue create \ --title "Bug: Login not working" \ --body "Steps to reproduce..." # Create with body from file gh issue create --body-file issue.md # Create with labels gh issue create --title "Fix bug" --labels bug,high-priority # Create with assignees gh issue create --title "Fix bug" --assignee user1,user2 # Create in specific repository gh issue create --repo owner/repo --title "Issue title" # Create issue from web gh issue create --web ``` ### List Issues ```bash # List all open issues gh issue list # List all issues (including closed) gh issue list --state all # List closed issues gh issue list --state closed # Limit results gh issue list --limit 50 # Filter by assignee gh issue list --assignee username gh issue list --assignee @me # Filter by labels gh issue list --labels bug,enhancement # Filter by milestone gh issue list --milestone "v1.0" # Search/filter gh issue list --search "is:open is:issue label:bug" # JSON output gh issue list --json number,title,state,author # Table view gh issue list --json number,title,labels --jq '.[] | [.number, .title, .labels[].name] | @tsv' # Show comments count gh issue list --json number,title,comments --jq '.[] | [.number, .title, .comments]' # Sort by gh issue list --sort created --order desc ``` ### View Issue ```bash # View issue gh issue view 123 # View with comments gh issue view 123 --comments # View in browser gh issue view 123 --web # JSON output gh issue view 123 --json title,body,state,labels,comments # View specific fields gh issue view 123 --json title --jq '.title' ``` ### Edit Issue ```bash # Edit interactively gh issue edit 123 # Edit title gh issue edit 123 --title "New title" # Edit body gh issue edit 123 --body "New description" # Add labels gh issue edit 123 --add-label bug,high-priority # Remove labels gh issue edit 123 --remove-label stale # Add assignees gh issue edit 123 --add-assignee user1,user2 # Remove assignees gh issue edit 123 --remove-assignee user1 # Set milestone gh issue edit 123 --milestone "v1.0" ``` ### Close/Reopen Issue ```bash # Close issue gh issue close 123 # Close with comment gh issue close 123 --comment "Fixed in PR #456" # Reopen issue gh issue reopen 123 ``` ### Comment on Issue ```bash # Add comment gh issue comment 123 --body "This looks good!" # Edit comment gh issue comment 123 --edit 456789 --body "Updated comment" # Delete comment gh issue comment 123 --delete 456789 ``` ### Issue Status ```bash # Show issue status summary gh issue status # Status for specific repository gh issue status --repo owner/repo ``` ### Pin/Unpin Issues ```bash # Pin issue (pinned to repo dashboard) gh issue pin 123 # Unpin issue gh issue unpin 123 ``` ### Lock/Unlock Issue
View on GitHub
This SKILL.md is very large, so SkillsMP previews the first section here. View on GitHub