Install the GitHub CLI

Next, you need to install the GitHub Command Line Interface (CLI) on your system. You can follow the official installation guide to install the GitHub CLI your preferred way. Alternatively, you can follow the steps below.

Install the GitHub CLI

The installation steps differ a bit depending on your operating system:

  1. Visit https://cli.github.com/ in your browser and click the Download button
  2. Locate the .msi GitHub CLI installer in your download folder
  3. Double-click the .msi file
  4. Follow the installation wizard instructions

On Debian and Ubuntu, install the GitHub CLI from GitHub’s official package repository. Don’t use the gh package from your distribution’s default sources, because its version is outdated and no longer works with GitHub. Copy the full command block from the official Linux installation guide and run it in your terminal. It adds the GitHub CLI repository and then installs gh:

Language: Shell
$ (type -p wget >/dev/null || (sudo apt update && sudo apt 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 \
    && sudo mkdir -p -m 755 /etc/apt/sources.list.d \
    && 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

On Fedora, CentOS, and Red Hat, add the GitHub CLI repository first and then install gh with dnf. The commands depend on your DNF version, so follow the RPM instructions in the official guide.

The most convenient way to install the GitHub CLI on macOS is with Homebrew. If you don’t have Homebrew installed yet, open your terminal and run:

Language: Shell
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Follow the prompts to complete the Homebrew installation. Make sure to also follow any instructions that Homebrew prints at the end — you may need to run a command to add Homebrew to your PATH.

Once Homebrew is ready, install the GitHub CLI:

Language: Shell
$ brew install gh

Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

Locked learning resources

The full lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Already a member? Sign-In

You must own this product to join the conversation.