macOS

brew install gh

MacPorts

sudo port install gh

Linux

Debian / Ubuntu (apt)

(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
  && sudo mkdir -p -m 755 /etc/apt/keyrings \
  && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
  && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
  && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
  && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
  && sudo apt update \
  && sudo apt install gh -y

Fedora / RHEL / CentOS (dnf)

sudo dnf install gh

Arch Linux

sudo pacman -S github-cli

openSUSE

sudo zypper install gh

Windows

winget install --id GitHub.cli

Scoop

scoop install gh

Chocolatey

choco install gh

MSI Installer

Download the .msi from the latest release.

Verify Installation

gh --version
# gh version 2.x.x (2024-xx-xx)

Upgrading

# macOS
brew upgrade gh
 
# Debian/Ubuntu
sudo apt update && sudo apt install gh
 
# Windows
winget upgrade --id GitHub.cli

Getting Help

Once installed, you can always access built-in help:

gh help              # General help
gh help <command>    # Help for a specific command
gh <command> --help  # Same thing
man gh               # Man pages (Linux/macOS)

Exercises

  1. Install gh on your machine using the method above for your OS
  2. Run gh --version and confirm the output
  3. Run gh help and read the list of available commands