GitHub Cheat Sheet
Repositories, pull requests, issues, Actions, releases, and API calls — the day-to-day GitHub workflows behind the platform.
gh CLI & Auth
6gh auth loginAuthenticate gh CLI
gh auth statusShow current auth state
gh auth tokenPrint the auth token
gh auth switchSwitch between accounts
gh config set user USERNAMESet a default account
gh versiongh version
Repositories
8gh repo create NAME --publicCreate a public repo
gh repo create NAME --private --source .Push an existing dir as a new repo
gh repo clone OWNER/REPOClone a repo
gh repo view OWNER/REPOView repo details in terminal
gh repo fork OWNER/REPO --cloneFork and clone
gh repo list OWNER --limit 50List repos
gh repo rename NEWRename the current repo
gh repo delete OWNER/REPODelete a repo
Pull Requests
10gh pr create --title "T" --body "D"Create a PR from the branch
gh pr create --draftOpen a draft PR
gh pr listList open PRs
gh pr list --state mergedMerged PRs
gh pr view NUMBERView a PR
gh pr checkout NUMBERCheck out the PR branch locally
gh pr diffShow the PR diff
gh pr statusPRs touching your branches
gh pr merge NUMBER --mergeMerge a PR (squash/rebase/merge)
gh pr close NUMBERClose without merging
Issues
6gh issue create --title "T" --body "D"Create an issue
gh issue listList open issues
gh issue list --label bugFilter by label
gh issue view NUMBERView an issue
gh issue close NUMBERClose an issue
gh issue transfer NUMBER TARGET_REPOMove to another repo
GitHub Actions
10gh workflow listWorkflows in the repo
gh workflow run CIManually trigger a workflow
gh workflow enable/dry-run NAMEEnable or dry-run a workflow
gh run list --workflow CIRecent runs
gh run list --branch mainRuns on a branch
gh run view RUN_IDDetails and logs of a run
gh run watch RUN_IDStream logs until done
gh run rerun RUN_ID --failedRe-run only failed jobs
gh run cancel RUN_IDCancel a run
gh run download RUN_IDDownload run artifacts
Releases & Gists
7gh release create v1.0.0 --generate-notesTag and create a release
gh release create v1.0.0 ./dist/*Attach build artifacts
gh release listList releases
gh release view v1.0.0View a release
gh release download v1.0.0 --pattern '*.tar.gz'Download matching assets
gh gist create FILECreate a gist
gh gist listList your gists
REST API
6gh api /repos/{owner}/{repo}Repo metadata
gh api /repos/{owner}/{repo}/actions/runs --paginate | jq '.workflow_runs[] | [.name, .status]'All workflow runs via API
gh api /repos/{owner}/{repo}/pulls --state=openOpen PRs via API
gh api -X PATCH /repos/{owner}/{repo} -f description='New desc'Update repo via API
gh api /search/issues -f q='repo:OWNER/REPO is:open'Search issues
gh api graphql -f query='{repository(owner:"o",name:"r"){stargazerCount}}'GraphQL query via gh
Settings & Security
8gh secret listRepo secrets
gh secret set NAMECreate/update a secret
gh secret set NAME --body "value"Set secret from a value
gh secret delete NAMEDelete a secret
gh variable listRepo variables
gh repo set-defaultSet the default repo for gh
gh label listRepo labels
gh alias set prc 'pr create --fill'Create a gh alias
Codespaces & Copilot
5gh codespace listYour codespaces
gh codespace create --repo OWNER/REPO --branch mainCreate a codespace
gh codespace sshSSH into a codespace
gh codespace portsForwarded ports
gh codespace delete -c CODESPACE_NAMEDelete a codespace