GitHub CLI (gh)
Pull requests, checking out and reviewing, CI runs and logs, issues, releases and raw API calls.
Setup
Log in
gh auth loginClone a repository
gh repo clone <gh_repo>
Open the repo in the browser
gh browsePull requests
Create a PR from the current branch
gh pr create --fillCreate a draft PR
gh pr create --draft --title "<pr_title>" --body ""
My open PRs and review requests
gh pr statusCheck out someone's PR locally
gh pr checkout <pr_number>
Show the PR diff
gh pr diff <pr_number>
Approve
gh pr review <pr_number> --approve
Squash-merge and delete the branch
gh pr merge <pr_number> --squash --delete-branch
Wait for checks to finishadvanced
gh pr checks <pr_number> --watch
CI (GitHub Actions)
Recent workflow runs
gh run list --limit 10Follow a run live
gh run watchLogs of failed steps only
gh run view <run_id> --log-failed
Re-run failed jobs
gh run rerun <run_id> --failed
Trigger a workflow manuallyadvanced
gh workflow run <workflow>.yml --ref main -f environment=staging
Set a repository secretadvanced
gh secret set <gh_secret> < secret.txt
Issues, releases, API
Issues assigned to me
gh issue list --assignee @meCreate a release with generated notes
gh release create <git_tag> --generate-notes
Call any API endpointadvanced
gh api repos/<gh_repo>/pulls --jq '.[].title'