Let's Move our GitHub to Terminal. Yes!! gh-CLI is available!!

rahulmanojt

Rahul T

Posted on September 18, 2020

Let's Move our GitHub to Terminal. Yes!! gh-CLI is available!!

Table of contents

GitHub CLI

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.

screenshot of gh pr status

Installation

macOS

gh is available via Homebrew and MacPorts.

Homebrew

Install: Upgrade:
brew install gh brew upgrade gh

MacPorts

Install: Upgrade:
sudo port install gh sudo port selfupdate && sudo port upgrade gh

Linux

Debian, Ubuntu Linux (apt)

Install:

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
Enter fullscreen mode Exit fullscreen mode

Note: most systems will have apt-add-repository already. If you get a command not found
error, try running sudo apt install software-properties-common and trying these steps again.

Upgrade:

sudo apt update
sudo apt install gh
Enter fullscreen mode Exit fullscreen mode

Fedora, Centos, Red Hat Linux (dnf)

Install:

sudo dnf config-manager --add-repo https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install gh
Enter fullscreen mode Exit fullscreen mode

Upgrade:

sudo dnf update gh
Enter fullscreen mode Exit fullscreen mode

openSUSE/SUSE Linux (zypper)

Install:

sudo zypper addrepo https://cli.github.com/packages/rpm/gh-cli.repo
sudo zypper ref
sudo zypper install gh
Enter fullscreen mode Exit fullscreen mode

Upgrade:

sudo zypper ref
sudo zypper update gh
Enter fullscreen mode Exit fullscreen mode

Community-supported methods

GitHub team does not directly maintain the following packages or repositories.

Arch Linux

Arch Linux users can install from the community repo:

sudo pacman -S github-cli
Enter fullscreen mode Exit fullscreen mode

Android

Android users can install via Termux:

pkg install gh
Enter fullscreen mode Exit fullscreen mode

Kiss Linux

Kiss Linux users can install from the community repos:

kiss b github-cli && kiss i github-cli
Enter fullscreen mode Exit fullscreen mode

Windows

gh is available via scoop, Chocolatey

scoop

Install:

scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop install gh
Enter fullscreen mode Exit fullscreen mode

Upgrade:

scoop update gh
Enter fullscreen mode Exit fullscreen mode

Chocolatey

Install: Upgrade:
choco install gh choco upgrade gh

Authentication

Run gh auth login to authenticate with your GitHub account

USAGE

gh <command> <subcommand> [flags]
Enter fullscreen mode Exit fullscreen mode

Core Commands

gist : Create gists

issue : Manage issues

pr : Manage pull requests

release : Manage GitHub releases

repo : Create, clone, fork, and view repositories

Additional Commands

alias: Create command shortcuts

api: Make an authenticated GitHub API request

auth: Login, logout, and refresh your authentication

completion: Generate shell completion scripts

config: Manage configuration for gh

help: Help about any command

Flags

--help: Show help for command

--version: Show gh version

Examples

Create gist

gh gist create --public hello.py
Enter fullscreen mode Exit fullscreen mode

Create Pull Request

gh pr create --title "The bug is fixed" --body "Everything works again"
gh pr create --reviewer monalisa,hubot
gh pr create --project "Roadmap"
gh pr create --base develop --head monalisa:feature
Enter fullscreen mode Exit fullscreen mode

Create a repo

gh repo create my-project
Enter fullscreen mode Exit fullscreen mode

Read more at https://cli.github.com/manual/

💖 💪 🙅 🚩
rahulmanojt
Rahul T

Posted on September 18, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related