macOS
Homebrew (recommended)
brew install ghMacPorts
sudo port install ghLinux
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 -yFedora / RHEL / CentOS (dnf)
sudo dnf install ghArch Linux
sudo pacman -S github-cliopenSUSE
sudo zypper install ghWindows
winget (recommended)
winget install --id GitHub.cliScoop
scoop install ghChocolatey
choco install ghMSI 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.cliGetting 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
- Install
ghon your machine using the method above for your OS - Run
gh --versionand confirm the output - Run
gh helpand read the list of available commands