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.
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/
Top comments (2)
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