GitHub CLI (gh) is the official command-line tool from GitHub that brings pull requests, issues, repositories, gists, and other GitHub features directly into your terminal. Instead of switching between your browser and terminal, you can manage your entire GitHub workflow from the command line. This guide covers installing GitHub CLI on Ubuntu 24.04, Debian 13, RHEL 10, Rocky Linux 10, Fedora 42, macOS, and Windows, plus authentication and everyday usage.
At the time of writing, the latest stable release is gh v2.88.1 (March 2026). GitHub CLI replaces the older hub command-line wrapper and is actively maintained by GitHub.
Prerequisites
Before you begin, make sure you have:
- A GitHub account
- A Linux, macOS, or Windows machine with internet access
- sudo or administrator privileges for package installation
- Git installed on your system
Step 1: Install GitHub CLI on Ubuntu / Debian
GitHub provides an official APT repository for Ubuntu and Debian systems. This method works on Ubuntu 24.04, Ubuntu 22.04, Debian 13, Debian 12, and related derivatives like Linux Mint.
First, install the required dependencies and add the GitHub CLI repository:
sudo apt update
sudo apt install -y curl gpg
sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
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
Now update the package index and install the gh package:
sudo apt update
sudo apt install -y gh
Confirm the installation by checking the version:
gh --version
You should see output similar to:
gh version 2.88.1 (2026-03-12)
https://github.com/cli/cli/releases/tag/v2.88.1
To upgrade GitHub CLI later, run a standard apt upgrade:
sudo apt update && sudo apt upgrade gh
Step 2: Install GitHub CLI on RHEL / Rocky Linux / Fedora
For RPM-based distributions including RHEL 10, Rocky Linux 10, AlmaLinux 10, and Fedora 42, GitHub maintains a DNF/YUM repository.
Add the official GitHub CLI repository and install:
sudo dnf install -y 'dnf-command(config-manager)'
sudo dnf config-manager addrepo --from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install -y gh
On older RHEL/CentOS systems that use yum, the commands are the same but use yum instead of dnf.
Verify the installation:
gh --version
Expected output:
gh version 2.88.1 (2026-03-12)
https://github.com/cli/cli/releases/tag/v2.88.1
Future upgrades happen automatically through dnf upgrade gh.
Step 3: Install GitHub CLI on macOS
On macOS, the easiest way to install GitHub CLI is through Homebrew. If you don’t have Homebrew installed, you can also download a binary from the GitHub CLI releases page.
Install using Homebrew:
brew install gh
Verify the installed version:
gh --version
To upgrade later:
brew upgrade gh
Step 4: Install GitHub CLI on Windows
On Windows, you can install GitHub CLI using either winget (built into Windows 11 and recent Windows 10 builds) or Chocolatey.
Option A: Install with winget
Open PowerShell or Command Prompt and run:
winget install --id GitHub.cli
After installation, restart your terminal session so the gh command becomes available in your PATH.
Option B: Install with Chocolatey
If you use Chocolatey as your Windows package manager, install with:
choco install gh
Option C: Install with Scoop
Scoop users can install GitHub CLI from the main bucket:
scoop install gh
Regardless of installation method, verify by opening a new terminal and running:
gh --version
Step 5: Authenticate with GitHub
After installing GitHub CLI, you need to authenticate before you can interact with GitHub. The gh auth login command walks you through an interactive flow.
Start the authentication process:
gh auth login
The CLI will prompt you to choose:
- Where to authenticate – Choose GitHub.com or GitHub Enterprise Server
- Preferred protocol – HTTPS or SSH
- Authentication method – Browser-based login (recommended) or paste a personal access token
For browser-based login, gh displays a one-time code. You open the URL shown in the terminal, enter the code, and authorize the CLI. This is the simplest approach and avoids handling tokens manually.
Once authenticated, verify your login status:
gh auth status
The output confirms which account is logged in and the active protocol:
github.com
✓ Logged in to github.com account yourname (keyring)
- Active account: true
- Git operations protocol: https
- Token: gho_************************************
- Token scopes: 'gist', 'read:org', 'repo', 'workflow'
If you need to authenticate with a personal access token instead (useful for CI/CD pipelines or automation), you can pass it directly:
echo "YOUR_TOKEN" | gh auth login --with-token
To log out or switch accounts later:
gh auth logout
gh auth login
Step 6: Common gh CLI Usage
With GitHub CLI installed and authenticated, here are the most common workflows you will use daily. The official gh CLI manual covers every command in detail.
Working with Repositories
Clone a repository directly using the owner/repo shorthand instead of typing full URLs:
gh repo clone owner/repository-name
Create a new repository interactively or with flags:
gh repo create my-project --public --clone
gh repo create my-private-app --private --clone
Fork and clone a repository in one step:
gh repo fork owner/repository-name --clone
View repository details from inside a cloned repo:
gh repo view
Managing Pull Requests
Pull request management is where gh saves the most time. You can create, review, merge, and check out PRs without leaving the terminal.
Create a pull request from your current branch:
gh pr create --title "Add user authentication" --body "Implements JWT-based auth"
List open pull requests in the current repository:
gh pr list
Check out a pull request locally for testing:
gh pr checkout 42
Review and merge a pull request:
gh pr review 42 --approve
gh pr merge 42 --squash
Working with Issues
Create, list, and manage issues directly from the command line:
gh issue create --title "Fix login timeout" --body "Login times out after 5 seconds on slow connections"
gh issue list
gh issue view 15
gh issue close 15
Managing Gists
Create gists from files or standard input:
gh gist create myfile.py --public --desc "Python helper script"
gh gist list
gh gist view GIST_ID
Checking Workflow Runs
GitHub Actions workflows can be monitored and triggered from the CLI:
gh run list
gh run view 123456789
gh run watch 123456789
gh workflow run deploy.yml
Essential gh CLI Commands Reference
The table below summarizes the most commonly used GitHub CLI commands for quick reference.
| Command | Description |
|---|---|
gh auth login | Authenticate with GitHub |
gh auth status | Check authentication status |
gh repo clone owner/repo | Clone a repository |
gh repo create name | Create a new repository |
gh repo fork owner/repo | Fork a repository |
gh pr create | Create a pull request |
gh pr list | List open pull requests |
gh pr checkout NUM | Check out a PR locally |
gh pr merge NUM | Merge a pull request |
gh pr diff NUM | View a PR diff in terminal |
gh issue create | Create a new issue |
gh issue list | List repository issues |
gh issue close NUM | Close an issue |
gh gist create FILE | Create a gist from a file |
gh run list | List recent workflow runs |
gh run watch NUM | Watch a workflow run live |
gh workflow run FILE | Trigger a workflow manually |
gh release create TAG | Create a new release |
gh api ENDPOINT | Make authenticated API calls |
gh ssh-key add FILE | Add an SSH key to your account |
Conclusion
GitHub CLI brings your full GitHub workflow into the terminal. You can manage repositories, pull requests, issues, gists, and Actions runs without opening a browser. The authentication system handles tokens securely, and the command structure is consistent and easy to learn.
If you work with Visual Studio Code or any terminal-based editor, pairing it with gh gives you a fast, keyboard-driven development workflow. For auditing secrets in your repositories, consider using Gitleaks to audit your Git repos. If you are hosting your own Git service, check out our guides on installing Gitea on Ubuntu or GitLab CE on CentOS/Fedora.