With GitHub CLI, you can: Run your entire GitHub workflow from the terminal, from issues through releases; Call the GitHub API to script nearly any action, and set a custom alias for any command, and Connect to GitHub Enterprise Server in addition to GitHub.com.
GitHub CLI works with repositories hosted on GitHub Enterprise Server 2.20+.
Through terminal, it reduces context switching, which helps to focus, and it’ll be easier to script and create workflows. It is available to download on Windows, macOS, and Linux.
Homebrew
brew install gh
brew upgrade gh
MacPorts
sudo port install gh
sudo port selfupdate && sudo port upgrade gh
scoop
scoop bucket add github-gh https://github.com/cli/scoop-gh.git
scoop install gh
Chocolatey
choco install gh
choco upgrade gh
gh auth login
to authenticate with your GitHub account. gh will respect tokens set using GITHUB_TOKEN
.GitHub CLI supports GHES 2.20 and above. To authenticate with a GitHub Enterprise instance, run: gh auth login --hostname <hostname>
$ gh auth login
# => do an interactive setup
$ gh auth login --with-token < mytoken.txt
# => read token from mytoken.txt and authenticate against github.com
$ gh auth login --hostname enterprise.internal --with-token < mytoken.txt
# => read token from mytoken.txt and authenticate against a GitHub Enterprise Server instance
gh auth status [flags]
gh config set git_protocol { ssh | https }
~/$ gh repo clone https://github.com/cli/cli
Cloning into 'cli'...
remote: Enumerating objects: 99, done.
remote: Counting objects: 100% (99/99), done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 21160 (delta 49), reused 35 (delta 18), pack-reused 21061
Receiving objects: 100% (21160/21160), 57.93 MiB | 10.82 MiB/s, done.
Resolving deltas: 100% (16051/16051), done.
~/$ gh pr status
Current branch
#12 Remove the test feature [user:patch-2]
- All checks failing - Review required
Created by you
You have no open pull requests
Requesting a code review from you
#13 Fix tests [branch]
- 3/4 checks failing - Review required
#15 New feature [branch]
- Checks passing - Approved
~/$
# Viewing a list of open issues
~/$ gh issue list
Issues for owner/repo
#14 Update the remote url if it changed (bug)
#14 PR commands on a detached head (enhancement)
#13 Support for GitHub Enterprise (wontfix)
#8 Add an easier upgrade command (bug)
~/$
gh pr create
gh pr checkout [request number]
gh pr diff
gh pr review
gh pr checks
gh pr merge
gh release create [tag name]
gh alias set
gh api
gh alias list | gh gist create
Do refer Online manual for more information. GitHub CLI is loaded with features. Share feedback or contribute to this awesome CLI.