loading...

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

rahulmanojcet profile image Rahul T ・3 min read

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/

Posted on by:

rahulmanojcet profile

Rahul T

@rahulmanojcet

Second Year CS student at College Of Engineering, Trivandrum.

Discussion

pic
Editor guide
 

Can I make a couple of suggestions?

Your installation instructions for "Linux" are for "Ubuntu" specifically and won't apply to any other distro. Perhaps you could include a note around that or say whether it is supported on any other distros?

The picture you include with example gh code is inaccessible - it's an image representing text. The alt attribute describes it but that doesn't convey the same information as the block itself. You could make it a code block and copy the text in instead?

 

Thanks for your suggestion.
As you mentioned I added the installation method for other linux distro's as well.
Also added some examples
Again Thankyou