How to install and setup GitHub CLI
Tags: linux, development, webdev, github
Published: 2020-10-22 08:42:30

---
title: How to install and setup GitHub CLI
published: true
description: GitHub has finally introduced its own command-line tool that brings pull requests, issues, and other GitHub concepts to the terminal.
tags: linux, development, webdev, github
cover_image: https://github.blog/wp-content/uploads/2020/09/GitHubCLI_SocialCard_VersionNumber_NoSubLine_v2.png?w=1200
---

You know how painful it is to switch from terminal to browser, then again to the terminal while working with git repositories right? Then worry not, because GitHub CLI brings GitHub to your terminal.

GitHub has finally introduced its own command-line tool that brings pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code. To quote GitHub it "reduces context switching, helps you focus, and enables you to more easily script and create your own workflows". Pretty cool right?

This post explains the installation and the setting-up of the GitHub CLI, hereby referred to as 'gh'.
# Installation
## Windows
gh can be installed on Windows using scoop or chocolatey package managers.
### scoop
```
scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop install gh
```
### chocolatey
```
choco install gh
```
## macOS
macOS users can use either Homebrew or MacPorts to install gh.
### Homebrew
```
brew install gh
```
### MacPorts
```
sudo port install gh
```
## Linux
### Debain-based
```
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
```
### Fedora-based
```
sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh
```
### Arch-based
```
sudo pacman -S github-cli
```
There are more distro-specific installation instructions [here](https://github.com/cli/cli/blob/trunk/docs/install_linux.md). Windows and macOS users can install using MSIs and downloadable binaries available on their [releases page](https://github.com/cli/cli/releases/).
# Setting up
After the installation, running any command will prompt you to login to GitHub.

![October 20 - 21-11-13.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603208428609/UfRuqTcJS.png)

Run 'gh auth login' to authenticate your GitHub account. It'll ask you to select the account type, either a normal account or an enterprise one. I'll select the normal account.

![October 20 - 21-13-28.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603208984153/H6Fjw-0fM.png)

Then it'll ask you to select your preferred authentication method. You can choose to authenticate using your browser or using the GitHub authentication token. I'll select the browser method.

![October 20 - 21-13-51.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603209242487/hZExrz5V9.png)

Then it'll display a one-time code, you should copy it or write it down.

![October 20 - 22-10-21.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603211945653/4klGcNROw.png)

And then pressing enter will open the browser. You should enter the one-time code here.

![October 20 - 21-16-16.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603209478689/xuCwFMG4i.png)

Then click on "Authorize github" to complete the authentication. You can safely close the browser now.

![October 20 - 21-17-08.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603209537008/qZA3AdOdN.png)

Now it'll ask you to select the default git protocol. You can select HTTPS or SSH. I'll be selecting SSH because I've already made an SSH key, and it's easy cloning and pushing to the repo using SSH.

![October 20 - 21-18-44.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603209746654/tMo-4NR8L.png)


![October 20 - 21-19-16.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1603209771638/-FcZ7xVD7.png)

Aaaand that's it. You've successfully installed and set up the GitHub CLI.
I'm also planning a post explaining all the gh commands and how to use it, so be on the lookout for that.