This guide will explain the installation steps for GitHub CLI on Linux – Ubuntu, Debian, CentOS, Fedora and Windows 10 or Windows server systems. GitHub CLI (gh) is a tool that brings on the Github features to the command line. This tool brings the pull requests, issues, and other GitHub concepts to the terminal next to where you are already working with git and your code.
The GitHub CLI (gh) is currently available in Beta and only for repos hosted on GitHub.com. The development team is planning to move the project out of beta (likely toward the end of 2020). At the moment GitHub CLI does not support repositories hosted on GitHub Enterprise Server or other hosting providers but once out of beta it will.
How To Install GitHub CLI on Linux
If you’re running any edition of Linux, the GitHub CLI binary should work for you without any issues.
You can view the latest version of gh using the following command:
VERSION=`curl "https://api.github.com/repos/cli/cli/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c2-`
echo $VERSION
Download the latest binary file.
### With wget ###
wget https://github.com/cli/cli/releases/download/v${VERSION}/gh_${VERSION}_linux_amd64.tar.gz
### With curl ###
curl -sSL https://github.com/cli/cli/releases/download/v${VERSION}/gh_${VERSION}_linux_amd64.tar.gz -o gh_${VERSION}_linux_amd64.tar.gz
Extract downloaded file:
tar xvf gh_${VERSION}_linux_amd64.tar.gz
Copy binary file to /usr/local/bin
directory.
sudo cp gh_${VERSION}_linux_amd64/bin/gh /usr/local/bin/
Version confirmation using gh command:
$ gh version
gh version 1.2.1 (2020-11-11)
https://github.com/cli/cli/releases/tag/v0.9.0
Copy man pages for gh.
sudo cp -r gh_${VERSION}_linux_amd64/share/man/man1/* /usr/share/man/man1/
You can see the complete list:
$ ls gh_${VERSION}_linux_amd64/share/man/man1/
gh.1 gh-config-set.1 gh-issue.1 gh-issue-reopen.1 gh-pr-checkout.1 gh-pr-list.1 gh-pr-review.1 gh-repo-clone.1
gh-completion.1 gh-credits.1 gh-issue-close.1 gh-issue-status.1 gh-pr-close.1 gh-pr-merge.1 gh-pr-status.1 gh-repo-create.1
gh-config.1 gh-gist.1 gh-issue-create.1 gh-issue-view.1 gh-pr-create.1 gh-pr-ready.1 gh-pr-view.1 gh-repo-fork.1
gh-config-get.1 gh-gist-create.1 gh-issue-list.1 gh-pr.1 gh-pr-diff.1 gh-pr-reopen.1 gh-repo.1 gh-repo-view.1
Man pages usage examples:
$ man gh
$ man gh-issue
$ man gh-pr
If you’re using Arch Linux, the gh can be installed from AUR:
$ yay -S github-cli
How To Install GitHub CLI (gh) on Windows
For Windows installation, you can use scoop or Chocolatey. Use our guides below as reference:
- How To Install Applications from Windows Command Line Interface
- Manage Windows Applications Using Chocolatey Software Management Tool
Once you have one of the tools installed, use it to get GitHub CLI onto your Windows machine.
--- Using Chocolatey ---
choco install gh
--- Using scoop ---
scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop install gh
Using GitHub command line tool
Visit the official docs for more information on the usage of the GitHub CLI (gh) tool.
Git Learning Video Courses
- The Git & Github Bootcamp
- Git Going Fast: One Hour Git Crash Course
- Git Complete: The definitive, step-by-step guide to Git
- Complete Git Guide: Understand and master Git and GitHub
- Git & GitHub For Beginners – Master Git and GitHub
More articles on Git.
Install posh-git on Windows – PowerShell environment for Git
How To Perform Git clone in Kubernetes Pod deployment