How to use Github Newly released CLI

GitHub CLI. gh is GitHub on the command line.

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

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

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

Upgrade:

sudo dnf update gh

openSUSE/SUSE Linux (zypper)

Install:

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

Upgrade:

sudo zypper ref
sudo zypper update gh

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

Android

Android users can install via Termux:

pkg install gh

Kiss Linux

Kiss Linux users can install from the community repos:

kiss b github-cli && kiss i github-cli

Windows

gh is available via scoop, Chocolatey

scoop

Install:

scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop install gh

Upgrade:

scoop update gh

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]

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

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

Create a repo

gh repo create my-project

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

  see all blogs

Go to Home