🐙 GitHub CLI Tutorial

📅 March 2026 ⏱️ 5 min read 🏷️ GitHub, CLI, Developer

Use the `gh` CLI to operate GitHub from the command line, including PRs, Issues, CI runs, and advanced API queries.

Installation

# macOS
brew install gh

# Linux
sudo apt install gh

# Windows
winget install GitHub.cli

Authentication

gh auth login

Common Commands

Pull Requests

# List PRs
gh pr list

# View PR checks
gh pr checks 55 --repo owner/repo

# Create PR
gh pr create --title "Fix bug" --body "Description"

Issues

# List issues
gh issue list

# Create issue
gh issue create --title "Bug report" --body "Details"

# Close issue
gh issue close 123

Workflow Runs

# List workflow runs
gh run list --repo owner/repo --limit 10

# View run details
gh run view <run-id> --repo owner/repo

# View failed logs
gh run view <run-id> --repo owner/repo --log-failed

API Queries

# Get PR details
gh api repos/owner/repo/pulls/55 --jq '.title, .state'

# List repo contents
gh api repos/owner/repo/contents --jq '.[].name'

Quick Reference

CommandDescription
gh pr listList PRs
gh pr createCreate PR
gh pr checksView CI status
gh issue listList Issues
gh run listList workflows
gh apiAPI query