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:
scoop bucket add github-gh https://github.com/cli/scoop-gh.git scoop install gh
brew install github
sudo apt install git && sudo dpkg -i gh_*_linux_amd64.deb
sudo yum localinstall gh_*_linux_amd64.rpm
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:
Simply press the Enter key to start the process as illustrated below:
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
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
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:
GitHub CLI: A Guide to GitHub from the Command Line