Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive GitHub CLI (gh) reference covering repos, issues, PRs, Actions, projects, releases, and more.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: gh-cli3description: 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.4---56# GitHub CLI (gh)78Comprehensive reference for GitHub CLI (gh) - work seamlessly with GitHub from the command line.910**Version:** 2.85.0 (current as of January 2026)1112## Prerequisites1314### Installation1516```bash17# macOS18brew install gh1920# Linux21curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg22echo "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/null23sudo apt update24sudo apt install gh2526# Windows27winget install --id GitHub.cli2829# Verify installation30gh --version31```3233### Authentication3435```bash36# Interactive login (default: github.com)37gh auth login3839# Login with specific hostname40gh auth login --hostname enterprise.internal4142# Login with token43gh auth login --with-token < mytoken.txt4445# Check authentication status46gh auth status4748# Switch accounts49gh auth switch --hostname github.com --user username5051# Logout52gh auth logout --hostname github.com --user username53```5455### Setup Git Integration5657```bash58# Configure git to use gh as credential helper59gh auth setup-git6061# View active token62gh auth token6364# Refresh authentication scopes65gh auth refresh --scopes write:org,read:public_key66```6768## CLI Structure6970```71gh # Root command72├── auth # Authentication73│ ├── login74│ ├── logout75│ ├── refresh76│ ├── setup-git77│ ├── status78│ ├── switch79│ └── token80├── browse # Open in browser81├── codespace # GitHub Codespaces82│ ├── code83│ ├── cp84│ ├── create85│ ├── delete86│ ├── edit87│ ├── jupyter88│ ├── list89│ ├── logs90│ ├── ports91│ ├── rebuild92│ ├── ssh93│ ├── stop94│ └── view95├── gist # Gists96│ ├── clone97│ ├── create98│ ├── delete99│ ├── edit100│ ├── list101│ ├── rename102│ └── view103├── issue # Issues104│ ├── create105│ ├── list106│ ├── status107│ ├── close108│ ├── comment109│ ├── delete110│ ├── develop111│ ├── edit112│ ├── lock113│ ├── pin114│ ├── reopen115│ ├── transfer116│ ├── unlock117│ └── view118├── org # Organizations119│ └── list120├── pr # Pull Requests121│ ├── create122│ ├── list123│ ├── status124│ ├── checkout125│ ├── checks126│ ├── close127│ ├── comment128│ ├── diff129│ ├── edit130│ ├── lock131│ ├── merge132│ ├── ready133│ ├── reopen134│ ├── revert135│ ├── review136│ ├── unlock137│ ├── update-branch138│ └── view139├── project # Projects140│ ├── close141│ ├── copy142│ ├── create143│ ├── delete144│ ├── edit145│ ├── field-create146│ ├── field-delete147│ ├── field-list148│ ├── item-add149│ ├── item-archive150│ ├── item-create151│ ├── item-delete152│ ├── item-edit153│ ├── item-list154│ ├── link155│ ├── list156│ ├── mark-template157│ ├── unlink158│ └── view159├── release # Releases160│ ├── create161│ ├── list162│ ├── delete163│ ├── delete-asset164│ ├── download165│ ├── edit166│ ├── upload167│ ├── verify168│ ├── verify-asset169│ └── view170├── repo # Repositories171│ ├── create172│ ├── list173│ ├── archive174│ ├── autolink175│ ├── clone176│ ├── delete177│ ├── deploy-key178│ ├── edit179│ ├── fork180│ ├── gitignore181│ ├── license182│ ├── rename183│ ├── set-default184│ ├── sync185│ ├── unarchive186│ └── view187├── cache # Actions caches188│ ├── delete189│ └── list190├── run # Workflow runs191│ ├── cancel192│ ├── delete193│ ├── download194│ ├── list195│ ├── rerun196│ ├── view197│ └── watch198├── workflow # Workflows199│ ├── disable200│ ├── enable201│ ├── list202│ ├── run203│ └── view204├── agent-task # Agent tasks205├── alias # Command aliases206│ ├── delete207│ ├── import208│ ├── list209│ └── set210├── api # API requests211├── attestation # Artifact attestations212│ ├── download213│ ├── trusted-root214│ └── verify215├── completion # Shell completion216├── config # Configuration217│ ├── clear-cache218│ ├── get219│ ├── list220│ └── set221├── extension # Extensions222│ ├── browse223│ ├── create224│ ├── exec225│ ├── install226│ ├── list227│ ├── remove228│ ├── search229│ └── upgrade230├── gpg-key # GPG keys231│ ├── add232│ ├── delete233│ └── list234├── label # Labels235│ ├── clone236│ ├── create237│ ├── delete238│ ├── edit239│ └── list240├── preview # Preview features241├── ruleset # Rulesets242│ ├── check243│ ├── list244│ └── view245├── search # Search246│ ├── code247│ ├── commits248│ ├── issues249│ ├── prs250│ └── repos251├── secret # Secrets252│ ├── delete253│ ├── list254│ └── set255├── ssh-key # SSH keys256│ ├── add257│ ├── delete258│ └── list259├── status # Status overview260└── variable # Variables261├── delete262├── get263├── list264└── set265```266267## Configuration268269### Global Configuration270271```bash272# List all configuration273gh config list274275# Get specific configuration value276gh config list git_protocol277gh config get editor278279# Set configuration value280gh config set editor vim281gh config set git_protocol ssh282gh config set prompt disabled283gh config set pager "less -R"284285# Clear configuration cache286gh config clear-cache287```288289### Environment Variables290291```bash292# GitHub token (for automation)293export GH_TOKEN=ghp_xxxxxxxxxxxx294295# GitHub hostname296export GH_HOST=github.com297298# Disable prompts299export GH_PROMPT_DISABLED=true300301# Custom editor302export GH_EDITOR=vim303304# Custom pager305export GH_PAGER=less306307# HTTP timeout308export GH_TIMEOUT=30309310# Custom repository (override default)311export GH_REPO=owner/repo312313# Custom git protocol314export GH_ENTERPRISE_HOSTNAME=hostname315```316317## Authentication (gh auth)318319### Login320321```bash322# Interactive login323gh auth login324325# Web-based authentication326gh auth login --web327328# With clipboard for OAuth code329gh auth login --web --clipboard330331# With specific git protocol332gh auth login --git-protocol ssh333334# With custom hostname (GitHub Enterprise)335gh auth login --hostname enterprise.internal336337# Login with token from stdin338gh auth login --with-token < token.txt339340# Insecure storage (plain text)341gh auth login --insecure-storage342```343344### Status345346```bash347# Show all authentication status348gh auth status349350# Show active account only351gh auth status --active352353# Show specific hostname354gh auth status --hostname github.com355356# Show token in output357gh auth status --show-token358359# JSON output360gh auth status --json hosts361362# Filter with jq363gh auth status --json hosts --jq '.hosts | add'364```365366### Switch Accounts367368```bash369# Interactive switch370gh auth switch371372# Switch to specific user/host373gh auth switch --hostname github.com --user monalisa374```375376### Token377378```bash379# Print authentication token380gh auth token381382# Token for specific host/user383gh auth token --hostname github.com --user monalisa384```385386### Refresh387388```bash389# Refresh credentials390gh auth refresh391392# Add scopes393gh auth refresh --scopes write:org,read:public_key394395# Remove scopes396gh auth refresh --remove-scopes delete_repo397398# Reset to default scopes399gh auth refresh --reset-scopes400401# With clipboard402gh auth refresh --clipboard403```404405### Setup Git406407```bash408# Setup git credential helper409gh auth setup-git410411# Setup for specific host412gh auth setup-git --hostname enterprise.internal413414# Force setup even if host not known415gh auth setup-git --hostname enterprise.internal --force416```417418## Browse (gh browse)419420```bash421# Open repository in browser422gh browse423424# Open specific path425gh browse script/426gh browse main.go:312427428# Open issue or PR429gh browse 123430431# Open commit432gh browse 77507cd94ccafcf568f8560cfecde965fcfa63433434# Open with specific branch435gh browse main.go --branch bug-fix436437# Open different repository438gh browse --repo owner/repo439440# Open specific pages441gh browse --actions # Actions tab442gh browse --projects # Projects tab443gh browse --releases # Releases tab444gh browse --settings # Settings page445gh browse --wiki # Wiki page446447# Print URL instead of opening448gh browse --no-browser449```450451## Repositories (gh repo)452453### Create Repository454455```bash456# Create new repository457gh repo create my-repo458459# Create with description460gh repo create my-repo --description "My awesome project"461462# Create public repository463gh repo create my-repo --public464465# Create private repository466gh repo create my-repo --private467468# Create with homepage469gh repo create my-repo --homepage https://example.com470471# Create with license472gh repo create my-repo --license mit473474# Create with gitignore475gh repo create my-repo --gitignore python476477# Initialize as template repository478gh repo create my-repo --template479480# Create repository in organization481gh repo create org/my-repo482483# Create without cloning locally484gh repo create my-repo --source=.485486# Disable issues487gh repo create my-repo --disable-issues488489# Disable wiki490gh repo create my-repo --disable-wiki491```492493### Clone Repository494495```bash496# Clone repository497gh repo clone owner/repo498499# Clone to specific directory500gh repo clone owner/repo my-directory501502# Clone with different branch503gh repo clone owner/repo --branch develop504```505506### List Repositories507508```bash509# List all repositories510gh repo list511512# List repositories for owner513gh repo list owner514515# Limit results516gh repo list --limit 50517518# Public repositories only519gh repo list --public520521# Source repositories only (not forks)522gh repo list --source523524# JSON output525gh repo list --json name,visibility,owner526527# Table output528gh repo list --limit 100 | tail -n +2529530# Filter with jq531gh repo list --json name --jq '.[].name'532```533534### View Repository535536```bash537# View repository details538gh repo view539540# View specific repository541gh repo view owner/repo542543# JSON output544gh repo view --json name,description,defaultBranchRef545546# View in browser547gh repo view --web548```549550### Edit Repository551552```bash553# Edit description554gh repo edit --description "New description"555556# Set homepage557gh repo edit --homepage https://example.com558559# Change visibility560gh repo edit --visibility private561gh repo edit --visibility public562563# Enable/disable features564gh repo edit --enable-issues565gh repo edit --disable-issues566gh repo edit --enable-wiki567gh repo edit --disable-wiki568gh repo edit --enable-projects569gh repo edit --disable-projects570571# Set default branch572gh repo edit --default-branch main573574# Rename repository575gh repo rename new-name576577# Archive repository578gh repo archive579gh repo unarchive580```581582### Delete Repository583584```bash585# Delete repository586gh repo delete owner/repo587588# Confirm without prompt589gh repo delete owner/repo --yes590```591592### Fork Repository593594```bash595# Fork repository596gh repo fork owner/repo597598# Fork to organization599gh repo fork owner/repo --org org-name600601# Clone after forking602gh repo fork owner/repo --clone603604# Remote name for fork605gh repo fork owner/repo --remote-name upstream606```607608### Sync Fork609610```bash611# Sync fork with upstream612gh repo sync613614# Sync specific branch615gh repo sync --branch feature616617# Force sync618gh repo sync --force619```620621### Set Default Repository622623```bash624# Set default repository for current directory625gh repo set-default626627# Set default explicitly628gh repo set-default owner/repo629630# Unset default631gh repo set-default --unset632```633634### Repository Autolinks635636```bash637# List autolinks638gh repo autolink list639640# Add autolink641gh repo autolink add \642--key-prefix JIRA- \643--url-template https://jira.example.com/browse/<num>644645# Delete autolink646gh repo autolink delete 12345647```648649### Repository Deploy Keys650651```bash652# List deploy keys653gh repo deploy-key list654655# Add deploy key656gh repo deploy-key add ~/.ssh/id_rsa.pub \657--title "Production server" \658--read-only659660# Delete deploy key661gh repo deploy-key delete 12345662```663664### Gitignore and License665666```bash667# View gitignore template668gh repo gitignore669670# View license template671gh repo license mit672673# License with full name674gh repo license mit --fullname "John Doe"675```676677## Issues (gh issue)678679### Create Issue680681```bash682# Create issue interactively683gh issue create684685# Create with title686gh issue create --title "Bug: Login not working"687688# Create with title and body689gh issue create \690--title "Bug: Login not working" \691--body "Steps to reproduce..."692693# Create with body from file694gh issue create --body-file issue.md695696# Create with labels697gh issue create --title "Fix bug" --labels bug,high-priority698699# Create with assignees700gh issue create --title "Fix bug" --assignee user1,user2701702# Create in specific repository703gh issue create --repo owner/repo --title "Issue title"704705# Create issue from web706gh issue create --web707```708709### List Issues710711```bash712# List all open issues713gh issue list714715# List all issues (including closed)716gh issue list --state all717718# List closed issues719gh issue list --state closed720721# Limit results722gh issue list --limit 50723724# Filter by assignee725gh issue list --assignee username726gh issue list --assignee @me727728# Filter by labels729gh issue list --labels bug,enhancement730731# Filter by milestone732gh issue list --milestone "v1.0"733734# Search/filter735gh issue list --search "is:open is:issue label:bug"736737# JSON output738gh issue list --json number,title,state,author739740# Table view741gh issue list --json number,title,labels --jq '.[] | [.number, .title, .labels[].name] | @tsv'742743# Show comments count744gh issue list --json number,title,comments --jq '.[] | [.number, .title, .comments]'745746# Sort by747gh issue list --sort created --order desc748```749750### View Issue751752```bash753# View issue754gh issue view 123755756# View with comments757gh issue view 123 --comments758759# View in browser760gh issue view 123 --web761762# JSON output763gh issue view 123 --json title,body,state,labels,comments764765# View specific fields766gh issue view 123 --json title --jq '.title'767```768769### Edit Issue770771```bash772# Edit interactively773gh issue edit 123774775# Edit title776gh issue edit 123 --title "New title"777778# Edit body779gh issue edit 123 --body "New description"780781# Add labels782gh issue edit 123 --add-label bug,high-priority783784# Remove labels785gh issue edit 123 --remove-label stale786787# Add assignees788gh issue edit 123 --add-assignee user1,user2789790# Remove assignees791gh issue edit 123 --remove-assignee user1792793# Set milestone794gh issue edit 123 --milestone "v1.0"795```796797### Close/Reopen Issue798799```bash800# Close issue801gh issue close 123802803# Close with comment804gh issue close 123 --comment "Fixed in PR #456"805806# Reopen issue807gh issue reopen 123808```809810### Comment on Issue811812```bash813# Add comment814gh issue comment 123 --body "This looks good!"815816# Edit comment817gh issue comment 123 --edit 456789 --body "Updated comment"818819# Delete comment820gh issue comment 123 --delete 456789821```822823### Issue Status824825```bash826# Show issue status summary827gh issue status828829# Status for specific repository830gh issue status --repo owner/repo831```832833### Pin/Unpin Issues834835```bash836# Pin issue (pinned to repo dashboard)837gh issue pin 123838839# Unpin issue840gh issue unpin 123841```842843### Lock/Unlock Issue844845```bash846# Lock conversation847gh issue lock 123848849# Lock with reason850gh issue lock 123 --reason off-topic851852# Unlock853gh issue unlock 123854```855856### Transfer Issue857858```bash859# Transfer to another repository860gh issue transfer 123 --repo owner/new-repo861```862863### Delete Issue864865```bash866# Delete issue867gh issue delete 123868869# Confirm without prompt870gh issue delete 123 --yes871```872873### Develop Issue (Draft PR)874875```bash876# Create draft PR from issue877gh issue develop 123878879# Create in specific branch880gh issue develop 123 --branch fix/issue-123881882# Create with base branch883gh issue develop 123 --base main884```885886## Pull Requests (gh pr)887888### Create Pull Request889890```bash891# Create PR interactively892gh pr create893894# Create with title895gh pr create --title "Feature: Add new functionality"896897# Create with title and body898gh pr create \899--title "Feature: Add new functionality" \900--body "This PR adds..."901902# Fill body from template903gh pr create --body-file .github/PULL_REQUEST_TEMPLATE.md904905# Set base branch906gh pr create --base main907908# Set head branch (default: current branch)909gh pr create --head feature-branch910911# Create draft PR912gh pr create --draft913914# Add assignees915gh pr create --assignee user1,user2916917# Add reviewers918gh pr create --reviewer user1,user2919920# Add labels921gh pr create --labels enhancement,feature922923# Link to issue924gh pr create --issue 123925926# Create in specific repository927gh pr create --repo owner/repo928929# Open in browser after creation930gh pr create --web931```932933### List Pull Requests934935```bash936# List open PRs937gh pr list938939# List all PRs940gh pr list --state all941942# List merged PRs943gh pr list --state merged944945# List closed (not merged) PRs946gh pr list --state closed947948# Filter by head branch949gh pr list --head feature-branch950951# Filter by base branch952gh pr list --base main953954# Filter by author955gh pr list --author username956gh pr list --author @me957958# Filter by assignee959gh pr list --assignee username960961# Filter by labels962gh pr list --labels bug,enhancement963964# Limit results965gh pr list --limit 50966967# Search968gh pr list --search "is:open is:pr label:review-required"969970# JSON output971gh pr list --json number,title,state,author,headRefName972973# Show check status974gh pr list --json number,title,statusCheckRollup --jq '.[] | [.number, .title, .statusCheckRollup[]?.status]'975976# Sort by977gh pr list --sort created --order desc978```979980### View Pull Request981982```bash983# View PR984gh pr view 123985986# View with comments987gh pr view 123 --comments988989# View in browser990gh pr view 123 --web991992# JSON output993gh pr view 123 --json title,body,state,author,commits,files994995# View diff996gh pr view 123 --json files --jq '.files[].path'997998# View with jq query999gh pr view 123 --json title,state --jq '"\(.title): \(.state)"'1000```10011002### Checkout Pull Request10031004```bash1005# Checkout PR branch1006gh pr checkout 12310071008# Checkout with specific branch name1009gh pr checkout 123 --branch name-12310101011# Force checkout1012gh pr checkout 123 --force1013```10141015### Diff Pull Request10161017```bash1018# View PR diff1019gh pr diff 12310201021# View diff with color1022gh pr diff 123 --color always10231024# Output to file1025gh pr diff 123 > pr-123.patch10261027# View diff of specific files1028gh pr diff 123 --name-only1029```10301031### Merge Pull Request10321033```bash1034# Merge PR1035gh pr merge 12310361037# Merge with specific method1038gh pr merge 123 --merge1039gh pr merge 123 --squash1040gh pr merge 123 --rebase10411042# Delete branch after merge1043gh pr merge 123 --delete-branch10441045# Merge with comment1046gh pr merge 123 --subject "Merge PR #123" --body "Merging feature"10471048# Merge draft PR1049gh pr merge 123 --admin10501051# Force merge (skip checks)1052gh pr merge 123 --admin1053```10541055### Close Pull Request10561057```bash1058# Close PR (as draft, not merge)1059gh pr close 12310601061# Close with comment1062gh pr close 123 --comment "Closing due to..."1063```10641065### Reopen Pull Request10661067```bash1068# Reopen closed PR1069gh pr reopen 1231070```10711072### Edit Pull Request10731074```bash1075# Edit interactively1076gh pr edit 12310771078# Edit title1079gh pr edit 123 --title "New title"10801081# Edit body1082gh pr edit 123 --body "New description"10831084# Add labels1085gh pr edit 123 --add-label bug,enhancement10861087# Remove labels1088gh pr edit 123 --remove-label stale10891090# Add assignees1091gh pr edit 123 --add-assignee user1,user210921093# Remove assignees1094gh pr edit 123 --remove-assignee user110951096# Add reviewers1097gh pr edit 123 --add-reviewer user1,user210981099# Remove reviewers1100gh pr edit 123 --remove-reviewer user111011102# Mark as ready for review1103gh pr edit 123 --ready1104```11051106### Ready for Review11071108```bash1109# Mark draft PR as ready1110gh pr ready 1231111```11121113### Pull Request Checks11141115```bash1116# View PR checks1117gh pr checks 12311181119# Watch checks in real-time1120gh pr checks 123 --watch11211122# Watch interval (seconds)1123gh pr checks 123 --watch --interval 51124```11251126### Comment on Pull Request11271128```bash1129# Add comment1130gh pr comment 123 --body "Looks good!"11311132# Comment on specific line1133gh pr comment 123 --body "Fix this" \1134--repo owner/repo \1135--head-owner owner --head-branch feature11361137# Edit comment1138gh pr comment 123 --edit 456789 --body "Updated"11391140# Delete comment1141gh pr comment 123 --delete 4567891142```11431144### Review Pull Request11451146```bash1147# Review PR (opens editor)1148gh pr review 12311491150# Approve PR1151gh pr review 123 --approve --body "LGTM!"11521153# Request changes1154gh pr review 123 --request-changes \1155--body "Please fix these issues"11561157# Comment on PR1158gh pr review 123 --comment --body "Some thoughts..."11591160# Dismiss review1161gh pr review 123 --dismiss1162```11631164### Update Branch11651166```bash1167# Update PR branch with latest base branch1168gh pr update-branch 12311691170# Force update1171gh pr update-branch 123 --force11721173# Use merge strategy1174gh pr update-branch 123 --merge1175```11761177### Lock/Unlock Pull Request11781179```bash1180# Lock PR conversation1181gh pr lock 12311821183# Lock with reason1184gh pr lock 123 --reason off-topic11851186# Unlock1187gh pr unlock 1231188```11891190### Revert Pull Request11911192```bash1193# Revert merged PR1194gh pr revert 12311951196# Revert with specific branch name1197gh pr revert 123 --branch revert-pr-1231198```11991200### Pull Request Status12011202```bash1203# Show PR status summary1204gh pr status12051206# Status for specific repository1207gh pr status --repo owner/repo1208```12091210## GitHub Actions12111212### Workflow Runs (gh run)12131214```bash1215# List workflow runs1216gh run list12171218# List for specific workflow1219gh run list --workflow "ci.yml"12201221# List for specific branch1222gh run list --branch main12231224# Limit results1225gh run list --limit 2012261227# JSON output1228gh run list --json databaseId,status,conclusion,headBranch12291230# View run details1231gh run view 12345678912321233# View run with verbose logs1234gh run view 123456789 --log12351236# View specific job1237gh run view 123456789 --job 98765432112381239# View in browser1240gh run view 123456789 --web12411242# Watch run in real-time1243gh run watch 12345678912441245# Watch with interval1246gh run watch 123456789 --interval 512471248# Rerun failed run1249gh run rerun 12345678912501251# Rerun specific job1252gh run rerun 123456789 --job 98765432112531254# Cancel run1255gh run cancel 12345678912561257# Delete run1258gh run delete 12345678912591260# Download run artifacts1261gh run download 12345678912621263# Download specific artifact1264gh run download 123456789 --name build12651266# Download to directory1267gh run download 123456789 --dir ./artifacts1268```12691270### Workflows (gh workflow)12711272```bash1273# List workflows1274gh workflow list12751276# View workflow details1277gh workflow view ci.yml12781279# View workflow YAML1280gh workflow view ci.yml --yaml12811282# View in browser1283gh workflow view ci.yml --web12841285# Enable workflow1286gh workflow enable ci.yml12871288# Disable workflow1289gh workflow disable ci.yml12901291# Run workflow manually1292gh workflow run ci.yml12931294# Run with inputs1295gh workflow run ci.yml \1296--raw-field \1297version="1.0.0" \1298environment="production"12991300# Run from specific branch1301gh workflow run ci.yml --ref develop1302```13031304### Action Caches (gh cache)13051306```bash1307# List caches1308gh cache list13091310# List for specific branch1311gh cache list --branch main13121313# List with limit1314gh cache list --limit 5013151316# Delete cache1317gh cache delete 12345678913181319# Delete all caches1320gh cache delete --all1321```13221323### Action Secrets (gh secret)13241325```bash1326# List secrets1327gh secret list13281329# Set secret (prompts for value)1330gh secret set MY_SECRET13311332# Set secret from environment1333echo "$MY_SECRET" | gh secret set MY_SECRET13341335# Set secret for specific environment1336gh secret set MY_SECRET --env production13371338# Set secret for organization1339gh secret set MY_SECRET --org orgname13401341# Delete secret1342gh secret delete MY_SECRET13431344# Delete from environment1345gh secret delete MY_SECRET --env production1346```13471348### Action Variables (gh variable)13491350```bash1351# List variables1352gh variable list13531354# Set variable1355gh variable set MY_VAR "some-value"13561357# Set variable for environment1358gh variable set MY_VAR "value" --env production13591360# Set variable for organization1361gh variable set MY_VAR "value" --org orgname13621363# Get variable value1364gh variable get MY_VAR13651366# Delete variable1367gh variable delete MY_VAR13681369# Delete from environment1370gh variable delete MY_VAR --env production1371```13721373## Projects (gh project)13741375```bash1376# List projects1377gh project list13781379# List for owner1380gh project list --owner owner13811382# Open projects1383gh project list --open13841385# View project1386gh project view 12313871388# View project items1389gh project view 123 --format json13901391# Create project1392gh project create --title "My Project"13931394# Create in organization1395gh project create --title "Project" --org orgname13961397# Create with readme1398gh project create --title "Project" --readme "Description here"13991400# Edit project1401gh project edit 123 --title "New Title"14021403# Delete project1404gh project delete 12314051406# Close project1407gh project close 12314081409# Copy project1410gh project copy 123 --owner target-owner --title "Copy"14111412# Mark template1413gh project mark-template 12314141415# List fields1416gh project field-list 12314171418# Create field1419gh project field-create 123 --title "Status" --datatype single_select14201421# Delete field1422gh project field-delete 123 --id 45614231424# List items1425gh project item-list 12314261427# Create item1428gh project item-create 123 --title "New item"14291430# Add item to project1431gh project item-add 123 --owner-owner --repo repo --issue 45614321433# Edit item1434gh project item-edit 123 --id 456 --title "Updated title"14351436# Delete item1437gh project item-delete 123 --id 45614381439# Archive item1440gh project item-archive 123 --id 45614411442# Link items1443gh project link 123 --id 456 --link-id 78914441445# Unlink items1446gh project unlink 123 --id 456 --link-id 78914471448# View project in browser1449gh project view 123 --web1450```14511452## Releases (gh release)14531454```bash1455# List releases1456gh release list14571458# View latest release1459gh release view14601461# View specific release1462gh release view v1.0.014631464# View in browser1465gh release view v1.0.0 --web14661467# Create release1468gh release create v1.0.0 \1469--notes "Release notes here"14701471# Create release with notes from file1472gh release create v1.0.0 --notes-file notes.md14731474# Create release with target1475gh release create v1.0.0 --target main14761477# Create release as draft1478gh release create v1.0.0 --draft14791480# Create pre-release1481gh release create v1.0.0 --prerelease14821483# Create release with title1484gh release create v1.0.0 --title "Version 1.0.0"14851486# Upload asset to release1487gh release upload v1.0.0 ./file.tar.gz14881489# Upload multiple assets1490gh release upload v1.0.0 ./file1.tar.gz ./file2.tar.gz14911492# Upload with label (casing sensitive)1493gh release upload v1.0.0 ./file.tar.gz --casing14941495# Delete release1496gh release delete v1.0.014971498# Delete with cleanup tag1499gh release delete v1.0.0 --yes15001501# Delete specific asset1502gh release delete-asset v1.0.0 file.tar.gz15031504# Download release assets1505gh release download v1.0.015061507# Download specific asset1508gh release download v1.0.0 --pattern "*.tar.gz"15091510# Download to directory1511gh release download v1.0.0 --dir ./downloads15121513# Download archive (zip/tar)1514gh release download v1.0.0 --archive zip15151516# Edit release1517gh release edit v1.0.0 --notes "Updated notes"15181519# Verify release signature1520gh release verify v1.0.015211522# Verify specific asset1523gh release verify-asset v1.0.0 file.tar.gz1524```15251526## Gists (gh gist)15271528```bash1529# List gists1530gh gist list15311532# List all gists (including private)1533gh gist list --public15341535# Limit results1536gh gist list --limit 2015371538# View gist1539gh gist view abc12315401541# View gist files1542gh gist view abc123 --files15431544# Create gist1545gh gist create script.py15461547# Create gist with description1548gh gist create script.py --desc "My script"15491550# Create public gist1551gh gist create script.py --public15521553# Create multi-file gist1554gh gist create file1.py file2.py15551556# Create from stdin1557echo "print('hello')" | gh gist create15581559# Edit gist1560gh gist edit abc12315611562# Delete gist1563gh gist delete abc12315641565# Rename gist file1566gh gist rename abc123 --filename old.py new.py15671568# Clone gist1569gh gist clone abc12315701571# Clone to directory1572gh gist clone abc123 my-directory1573```15741575## Codespaces (gh codespace)15761577```bash1578# List codespaces1579gh codespace list15801581# Create codespace1582gh codespace create15831584# Create with specific repository1585gh codespace create --repo owner/repo15861587# Create with branch1588gh codespace create --branch develop15891590# Create with specific machine1591gh codespace create --machine premiumLinux15921593# View codespace details1594gh codespace view15951596# SSH into codespace1597gh codespace ssh15981599# SSH with specific command1600gh codespace ssh --command "cd /workspaces && ls"16011602# Open codespace in browser1603gh codespace code16041605# Open in VS Code1606gh codespace code --codec16071608# Open with specific path1609gh codespace code --path /workspaces/repo16101611# Stop codespace1612gh codespace stop16131614# Delete codespace1615gh codespace delete16161617# View logs1618gh codespace logs16191620--tail 10016211622# View ports1623gh codespace ports16241625# Forward port1626gh codespace cp 8080:808016271628# Rebuild codespace1629gh codespace rebuild16301631# Edit codespace1632gh codespace edit --machine standardLinux16331634# Jupyter support1635gh codespace jupyter16361637# Copy files to/from codespace1638gh codespace cp file.txt :/workspaces/file.txt1639gh codespace cp :/workspaces/file.txt ./file.txt1640```16411642## Organizations (gh org)16431644```bash1645# List organizations1646gh org list16471648# List for user1649gh org list --user username16501651# JSON output1652gh org list --json login,name,description16531654# View organization1655gh org view orgname16561657# View organization members1658gh org view orgname --json members --jq '.members[] | .login'1659```16601661## Search (gh search)16621663```bash1664# Search code1665gh search code "TODO"16661667# Search in specific repository1668gh search code "TODO" --repo owner/repo16691670# Search commits1671gh search commits "fix bug"16721673# Search issues1674gh search issues "label:bug state:open"16751676# Search PRs1677gh search prs "is:open is:pr review:required"16781679# Search repositories1680gh search repos "stars:>1000 language:python"16811682# Limit results1683gh search repos "topic:api" --limit 5016841685# JSON output1686gh search repos "stars:>100" --json name,description,stargazers16871688# Order results1689gh search repos "language:rust" --order desc --sort stars16901691# Search with extensions1692gh search code "import" --extension py16931694# Web search (open in browser)1695gh search prs "is:open" --web1696```16971698## Labels (gh label)16991700```bash1701# List labels1702gh label list17031704# Create label1705gh label create bug --color "d73a4a" --description "Something isn't working"17061707# Create with hex color1708gh label create enhancement --color "#a2eeef"17091710# Edit label1711gh label edit bug --name "bug-report" --color "ff0000"17121713# Delete label1714gh label delete bug17151716# Clone labels from repository1717gh label clone owner/repo17181719# Clone to specific repository1720gh label clone owner/repo --repo target/repo1721```17221723## SSH Keys (gh ssh-key)17241725```bash1726# List SSH keys1727gh ssh-key list17281729# Add SSH key1730gh ssh-key add ~/.ssh/id_rsa.pub --title "My laptop"17311732# Add key with type1733gh ssh-key add ~/.ssh/id_ed25519.pub --type "authentication"17341735# Delete SSH key1736gh ssh-key delete 1234517371738# Delete by title1739gh ssh-key delete --title "My laptop"1740```17411742## GPG Keys (gh gpg-key)17431744```bash1745# List GPG keys1746gh gpg-key list17471748# Add GPG key1749gh gpg-key add ~/.ssh/id_rsa.pub17501751# Delete GPG key1752gh gpg-key delete 1234517531754# Delete by key ID1755gh gpg-key delete ABCD12341756```17571758## Status (gh status)17591760```bash1761# Show status overview1762gh status17631764# Status for specific repositories1765gh status --repo owner/repo17661767# JSON output1768gh status --json1769```17701771## Configuration (gh config)17721773```bash1774# List all config1775gh config list17761777# Get specific value1778gh config get editor17791780# Set value1781gh config set editor vim17821783# Set git protocol1784gh config set git_protocol ssh17851786# Clear cache1787gh config clear-cache17881789# Set prompt behavior1790gh config set prompt disabled1791gh config set prompt enabled1792```17931794## Extensions (gh extension)17951796```bash1797# List installed extensions1798gh extension list17991800# Search extensions1801gh extension search github18021803# Install extension1804gh extension install owner/extension-repo18051806# Install from branch1807gh extension install owner/extension-repo --branch develop18081809# Upgrade extension1810gh extension upgrade extension-name18111812# Remove extension1813gh extension remove extension-name18141815# Create new extension1816gh extension create my-extension18171818# Browse extensions1819gh extension browse18201821# Execute extension command1822gh extension exec my-extension --arg value1823```18241825## Aliases (gh alias)18261827```bash1828# List aliases1829gh alias list18301831# Set alias1832gh alias set prview 'pr view --web'18331834# Set shell alias1835gh alias set co 'pr checkout' --shell18361837# Delete alias1838gh alias delete prview18391840# Import aliases1841gh alias import ./aliases.sh1842```18431844## API Requests (gh api)18451846```bash1847# Make API request1848gh api /user18491850# Request with method1851gh api --method POST /repos/owner/repo/issues \1852--field title="Issue title" \1853--field body="Issue body"18541855# Request with headers1856gh api /user \1857--header "Accept: application/vnd.github.v3+json"18581859# Request with pagination1860gh api /user/repos --paginate18611862# Raw output (no formatting)1863gh api /user --raw18641865# Include headers in output1866gh api /user --include18671868# Silent mode (no progress output)1869gh api /user --silent18701871# Input from file1872gh api --input request.json18731874# jq query on response1875gh api /user --jq '.login'18761877# Field from response1878gh api /repos/owner/repo --jq '.stargazers_count'18791880# GitHub Enterprise1881gh api /user --hostname enterprise.internal18821883# GraphQL query1884gh api graphql \1885-f query='1886{1887viewer {1888login1889repositories(first: 5) {1890nodes {1891name1892}1893}1894}1895}'1896```18971898## Rulesets (gh ruleset)18991900```bash1901# List rulesets1902gh ruleset list19031904# View ruleset1905gh ruleset view 12319061907# Check ruleset1908gh ruleset check --branch feature19091910# Check specific repository1911gh ruleset check --repo owner/repo --branch main1912```19131914## Attestations (gh attestation)19151916```bash1917# Download attestation1918gh attestation download owner/repo \1919--artifact-id 12345619201921# Verify attestation1922gh attestation verify owner/repo19231924# Get trusted root1925gh attestation trusted-root1926```19271928## Completion (gh completion)19291930```bash1931# Generate shell completion1932gh completion -s bash > ~/.gh-complete.bash1933gh completion -s zsh > ~/.gh-complete.zsh1934gh completion -s fish > ~/.gh-complete.fish1935gh completion -s powershell > ~/.gh-complete.ps119361937# Shell-specific instructions1938gh completion --shell=bash1939gh completion --shell=zsh1940```19411942## Preview (gh preview)19431944```bash1945# List preview features1946gh preview19471948# Run preview script1949gh preview prompter1950```19511952## Agent Tasks (gh agent-task)19531954```bash1955# List agent tasks1956gh agent-task list19571958# View agent task1959gh agent-task view 12319601961# Create agent task1962gh agent-task create --description "My task"1963```19641965## Global Flags19661967| Flag | Description |1968| -------------------------- | -------------------------------------- |1969| `--help` / `-h` | Show help for command |1970| `--version` | Show gh version |1971| `--repo [HOST/]OWNER/REPO` | Select another repository |1972| `--hostname HOST` | GitHub hostname |1973| `--jq EXPRESSION` | Filter JSON output |1974| `--json FIELDS` | Output JSON with specified fields |1975| `--template STRING` | Format JSON using Go template |1976| `--web` | Open in browser |1977| `--paginate` | Make additional API calls |1978| `--verbose` | Show verbose output |1979| `--debug` | Show debug output |1980| `--timeout SECONDS` | Maximum API request duration |1981| `--cache CACHE` | Cache control (default, force, bypass) |19821983## Output Formatting19841985### JSON Output19861987```bash1988# Basic JSON1989gh repo view --json name,description19901991# Nested fields1992gh repo view --json owner,name --jq '.owner.login + "/" + .name'19931994# Array operations1995gh pr list --json number,title --jq '.[] | select(.number > 100)'19961997# Complex queries1998gh issue list --json number,title,labels \1999--jq '.[] | {number, title: .title, tags: [.labels[].name]}'2000```20012002### Template Output20032004```bash2005# Custom template2006gh repo view \2007--template '{{.name}}: {{.description}}'20082009# Multiline template2010gh pr view 123 \2011--template 'Title: {{.title}}2012Author: {{.author.login}}2013State: {{.state}}2014'2015```20162017## Common Workflows20182019### Create PR from Issue20202021```bash2022# Create branch from issue2023gh issue develop 123 --branch feature/issue-12320242025# Make changes, commit, push2026git add .2027git commit -m "Fix issue #123"2028git push20292030# Create PR linking to issue2031gh pr create --title "Fix #123" --body "Closes #123"2032```20332034### Bulk Operations20352036```bash2037# Close multiple issues2038gh issue list --search "label:stale" \2039--json number \2040--jq '.[].number' | \2041xargs -I {} gh issue close {} --comment "Closing as stale"20422043# Add label to multiple PRs2044gh pr list --search "review:required" \2045--json number \2046--jq '.[].number' | \2047xargs -I {} gh pr edit {} --add-label needs-review2048```20492050### Repository Setup Workflow20512052```bash2053# Create repository with initial setup2054gh repo create my-project --public \2055--description "My awesome project" \2056--clone \2057--gitignore python \2058--license mit20592060cd my-project20612062# Set up branches2063git checkout -b develop2064git push -u origin develop20652066# Create labels2067gh label create bug --color "d73a4a" --description "Bug report"2068gh label create enhancement --color "a2eeef" --description "Feature request"2069gh label create documentation --color "0075ca" --description "Documentation"2070```20712072### CI/CD Workflow20732074```bash2075# Run workflow and wait2076RUN_ID=$(gh workflow run ci.yml --ref main --jq '.databaseId')20772078# Watch the run2079gh run watch "$RUN_ID"20802081# Download artifacts on completion2082gh run download "$RUN_ID" --dir ./artifacts2083```20842085### Fork Sync Workflow20862087```bash2088# Fork repository2089gh repo fork original/repo --clone20902091cd repo20922093# Add upstream remote2094git remote add upstream https://github.com/original/repo.git20952096# Sync fork2097gh repo sync20982099# Or manual sync2100git fetch upstream2101git checkout main2102git merge upstream/main2103git push origin main2104```21052106## Environment Setup21072108### Shell Integration21092110```bash2111# Add to ~/.bashrc or ~/.zshrc2112eval "$(gh completion -s bash)" # or zsh/fish21132114# Create useful aliases2115alias gs='gh status'2116alias gpr='gh pr view --web'2117alias gir='gh issue view --web'2118alias gco='gh pr checkout'2119```21202121### Git Configuration21222123```bash2124# Use gh as credential helper2125gh auth setup-git21262127# Set gh as default for repo operations2128git config --global credential.helper 'gh !gh auth setup-git'21292130# Or manually2131git config --global credential.helper github2132```21332134## Best Practices213521361. **Authentication**: Use environment variables for automation21372138```bash2139export GH_TOKEN=$(gh auth token)2140```214121422. **Default Repository**: Set default to avoid repetition21432144```bash2145gh repo set-default owner/repo2146```214721483. **JSON Parsing**: Use jq for complex data extraction21492150```bash2151gh pr list --json number,title --jq '.[] | select(.title | contains("fix"))'2152```215321544. **Pagination**: Use --paginate for large result sets21552156```bash2157gh issue list --state all --paginate2158```215921605. **Caching**: Use cache control for frequently accessed data2161```bash2162gh api /user --cache force2163```21642165## Getting Help21662167```bash2168# General help2169gh --help21702171# Command help2172gh pr --help2173gh issue create --help21742175# Help topics2176gh help formatting2177gh help environment2178gh help exit-codes2179gh help accessibility2180```21812182## References21832184- Official Manual: https://cli.github.com/manual/2185- GitHub Docs: https://docs.github.com/en/github-cli2186- REST API: https://docs.github.com/en/rest2187- GraphQL API: https://docs.github.com/en/graphql2188