Search for a command to run...
Install GitHub CLI 2.102 on Linux, macOS and Windows, authenticate with GitHub, and manage pull requests, issues, workflows and releases from your terminal.
GitHub CLI (gh) is GitHub's official command-line tool. It brings pull requests, issues,
workflows and releases into the terminal, next to where you already work with git.
GitHub CLI 2.102.1 · the official cli.github.com apt and rpm repositories ·
PGP key rotation effective 5 September 2026 · immutable releases since v2.93.0
GitHub CLI's Linux packages are signed with two keys. If apt update or dnf install
fails with a key error, your machine still trusts the old key. Re-import the keyring
file and the fingerprints are:
2C6106201985B60E6C7AC87323F3D4EA75716059 and
7F38BBB59D064DBCB3D84D725612B36462313325.
git on your PATH — gh shells out to it for most commands# Install the keyring and the repository in one step
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
# Verify
gh --versioncurl -fsSL -o - https://cli.github.com/packages/githubcli-archive-keyring.gpg | gpg --show-keysThe fingerprints must match the ones listed above before you import the key.
# Interactive login — choose the host, protocol and browser or device code
gh auth login
# For a headless machine, print a code instead of opening a browser
gh auth login --web
# Choose the git protocol used for clones (ssh or https)
gh auth login --git-protocol ssh
# For GitHub Enterprise Server
gh auth login --hostname ghe.example.com# Check which accounts are configured
gh auth status
# Switch between accounts
gh auth switch --hostname github.com --user octocat
# Let gh configure git to use its credentials
gh auth setup-git
# Refresh an expiring token
gh auth refresh --scopes repo,workflow
# Print the token (for scripts)
gh auth token# GitHub Actions
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr list# Or use the fine-grained token
export GH_TOKEN=ghp_xxxxxxxxxxxx
export GH_HOST=github.com| Variable | Purpose |
|---|---|
GH_TOKEN | Token used for API requests |
GH_ENTERPRISE_TOKEN | Token for GitHub Enterprise Server |
GH_HOST | Default hostname, for example ghe.example.com |
GH_EDITOR | Editor used by gh pr create and friends |
GH_BROWSER | Browser opened by gh browse and gh pr create |
GH_REPO | Default repository, so you can skip the flags |
GH_TELEMETRY | Set to 0 to disable usage telemetry |
# Create a pull request from the current branch
gh pr create --title "Add login" --body "Closes #42" --base main
# List, view and check out
gh pr list --state open
gh pr view 123 --web
gh pr checkout 123
# Review, merge and clean up
gh pr diff 123
gh pr review 123 --approve
gh pr merge 123 --squash --delete-branch
gh pr update-branch 123# Search across GitHub
gh search issues "flaky test" --owner octocat
gh search code "retry" --repo cli/cli
gh search repos "devops" --limit 20
# Issues
gh issue create --title "Bug" --body "Details" --label bug
gh issue list --assignee @me
gh issue close 42 --comment "Fixed in #43"# List the workflows and trigger one
gh workflow list
gh workflow run deploy.yml --ref main
# Watch a run
gh run list --workflow ci.yml
gh run watch 123456789
gh run view 123456789 --log-failed
gh run rerun 123456789 --failed
gh run download 123456789 --name artifacts# Clone, fork and create
gh repo clone cli/cli
gh repo fork cli/cli --clone
gh repo create my-project --private --push
# Browse files in the repository
gh repo view --web
gh browse --branch main# Repository secrets and variables
gh secret set API_KEY --body "value"
gh secret list
gh variable set LOG_LEVEL --body "debug"
# Releases
gh release create v1.2.0 --generate-notes
gh release upload v1.2.0 ./dist/app.tar.gz
gh release view v1.2.0# Verify a build attestation
gh attestation verify oci://ghcr.io/owner/image:v1 --repo owner/repo
# Install the agent skill that lets a coding agent drive gh
gh skill install cli/cli gh --scope user
# Extensions, aliases and configuration
gh extension install dlvhdr/gh-dash
gh alias set co "pr checkout"
gh config set editor vimgh auth login once per machine and use gh auth setup-git so git uses the
same credentials.GH_REPO in CI to avoid repeating -R on every command.GITHUB_TOKEN in GitHub Actions, never a personal access token.gh api for anything the CLI does not wrap — it is the full REST API.GH_TELEMETRY=0 if your organisation does not want usage telemetry.gh attestation verify before you trust a downloaded binary.Install Git 2.56 on Linux, macOS and Windows, configure your identity, SSH keys, credential helpers and commit signing, and work with branches the modern way.
Install GitLab CLI 1.124 on Linux, macOS and Windows, authenticate with OAuth or a token, and manage merge requests, pipelines, runners and releases from your terminal.