What is GitHub CLI and how to use it?
In this article, I will be giving you a brief introduction of GitHub CLI and tell you how to install it on your device.
As you may already know, GitHub CLI brings GitHub to your terminal. It reduces context switching, helps you focus, and enables you to more easily script and create your own workflows. With GitHub CLI 1.0, you can:
- Run your entire GitHub workflow from the terminal, from issues through releases
- Call the GitHub API to script nearly any action, and set a custom alias for any command
- Connect to GitHub Enterprise Server in addition to GitHub.com
gh
is GitHub on the command line. It brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git
and your code. Some examples of usage are shown below. (Image source github.blog).
GitHub CLI is available for repositories hosted on GitHub.com and GitHub Enterprise Server 2.20+, and to install on macOS, Windows, and Linux.
You can read the official documentation here.
Install GitHub CLI on Ubuntu/Debian:
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key C99B11DEB97541F0
$ sudo apt-add-repository https://cli.github.com/packages
$ sudo apt update
$ sudo apt install gh
Install GitHub CLI on Mac:
If you have MacPorts, the easiest way to install it is using the command sudo port install gh
.
Install GitHub CLI on Windows:
gh
is available via scoop, Chocolatey, and as a downloadable MSI for Windows.
To install using scoop use the below commands.
$ scoop bucket add github-gh https://github.com/cli/scoop-gh.git
$ scoop install gh$ scoop update gh
To install using chocolatey, use choco install gh
.
Or, You can just download this MSI file and run it. This should install GitHub CLI v1.0.0.
Hope this article helped you.
Edit 1:
I just realized I haven’t mentioned how to verify your installation. You can do this by typing gh — -version
in your terminal.