Skip to main content

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

Authentication

Setup Git Integration

CLI Structure

Configuration

Global Configuration

Environment Variables

Authentication (gh auth)

Login

Status

Switch Accounts

Token

Refresh

Setup Git

Browse (gh browse)

Repositories (gh repo)

Create Repository

Clone Repository

List Repositories

View Repository

Edit Repository

Delete Repository

Fork Repository

Sync Fork

Set Default Repository

Repository Deploy Keys

Gitignore and License

Issues (gh issue)

Create Issue

List Issues

View Issue

Edit Issue

Close/Reopen Issue

Comment on Issue

Issue Status

Pin/Unpin Issues

Lock/Unlock Issue

Transfer Issue

Delete Issue

Develop Issue (Draft PR)

Pull Requests (gh pr)

Create Pull Request

List Pull Requests

View Pull Request

Checkout Pull Request

Diff Pull Request

Merge Pull Request

Close Pull Request

Reopen Pull Request

Edit Pull Request

Ready for Review

Pull Request Checks

Comment on Pull Request

Review Pull Request

Update Branch

Lock/Unlock Pull Request

Revert Pull Request

Pull Request Status

GitHub Actions

Workflow Runs (gh run)

Workflows (gh workflow)

Action Caches (gh cache)

Action Secrets (gh secret)

Action Variables (gh variable)

Projects (gh project)

Releases (gh release)

Gists (gh gist)

Codespaces (gh codespace)

Organizations (gh org)

Labels (gh label)

SSH Keys (gh ssh-key)

GPG Keys (gh gpg-key)

Status (gh status)

Configuration (gh config)

Extensions (gh extension)

Aliases (gh alias)

API Requests (gh api)

Rulesets (gh ruleset)

Attestations (gh attestation)

Completion (gh completion)

Preview (gh preview)

Agent Tasks (gh agent-task)

Global Flags

Output Formatting

JSON Output

Template Output

Common Workflows

Create PR from Issue

Bulk Operations

Repository Setup Workflow

CI/CD Workflow

Fork Sync Workflow

Environment Setup

Shell Integration

Git Configuration

Best Practices

  1. Authentication: Use environment variables for automation
  2. Default Repository: Set default to avoid repetition
  3. JSON Parsing: Use jq for complex data extraction
  4. Pagination: Use —paginate for large result sets
  5. Caching: Use cache control for frequently accessed data

Getting Help

References