GitHub CLI: A Guide to GitHub from the Command Line

A Quickstart Guide to GitHub CLI

In this quickstart guide, you’ll learn GitHub CLI.

If you’re already familiar with Git commands, you’re obviously aware that you need to switch to the web browser in order to perform various actions on your GitHub repository. With the new GitHub CLI tool, you can execute many of these actions without leaving the command-line interface.


To get started, simply visit the installation page and find instructions on how to install GitHub CLI for your operating system. For Windows and macOS, you can use package managers to install and keep GitHub CLI up to date. For Linux users, you’ll need to download the package from the latest release page. There are Signed MSI installers for Windows users too, but be aware you have to re-download and update the tool manually if you opt for this. The easiest way for Windows users is to use the scoop package manager.

Below are snapshots of install instructions for each supported platform:

  • Windows:

    scoop bucket add github-gh
    scoop install gh
  • macOS:

    brew install github
  • Debian/Ubuntu Linux:

    sudo apt install git && sudo dpkg -i gh_*_linux_amd64.deb
  • Fedora/Centos Linux:

    sudo yum localinstall gh_*_linux_amd64.rpm
  • Arch Linux:

    yay -S github-cli

On Windows, I would recommend the use of the Git Bash terminal. This interface will allow you to access common Linux commands and Bash features such as autocompletion. It’s also officially supported by Visual Studio Code via terminal integration.

After installing GitHub CLI, you’ll need to authenticate your account. Running any command will trigger this authentication process. For example, try gh repo view cli/cli. For first-time users, you’ll be prompted with the following:

GitHub authentication

Simply press the Enter key to start the process as illustrated below:

Gitub authorization

Once you provide your password, you’ll get a “Successfully authenticated GitHub CLI” message. You’re now able to interact with the GitHub platform via the command-line terminal. The next step is to implement autocomplete, which is optional. Simply add this line to your ~/.bash_profile:

eval "$(gh completion -s bash)"

You can also run the above command in your current terminal to get the autocomplete feature without restarting your terminal. To confirm it’s working, type gh repo, then press tab twice. It should show you four different commands you can append to the current repo command.

Command Structure

The gh command structure is tree-like and easy to remember. There are basically two levels of commands. The first level only consists of six commands:

Continue reading
GitHub CLI: A Guide to GitHub from the Command Line
on SitePoint.

Leave a Reply

Your email address will not be published. Required fields are marked *