{"id":57388,"date":"2026-03-22T17:32:03","date_gmt":"2026-03-22T14:32:03","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=57388"},"modified":"2026-03-22T17:32:04","modified_gmt":"2026-03-22T14:32:04","slug":"how-to-install-github-cli-on-linux-and-windows","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/how-to-install-github-cli-on-linux-and-windows\/","title":{"rendered":"Install GitHub CLI (gh) on Linux, macOS, and Windows"},"content":{"rendered":"\n<p>GitHub CLI (<code>gh<\/code>) 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.<\/p>\n\n\n\n<p>At the time of writing, the latest stable release is <strong>gh v2.88.1<\/strong> (March 2026). GitHub CLI replaces the older <code>hub<\/code> command-line wrapper and is actively maintained by GitHub.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>Before you begin, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A <a href=\"https:\/\/github.com\" target=\"_blank\" rel=\"noopener\">GitHub account<\/a><\/li>\n\n\n\n<li>A Linux, macOS, or Windows machine with internet access<\/li>\n\n\n\n<li>sudo or administrator privileges for package installation<\/li>\n\n\n\n<li>Git installed on your system<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Install GitHub CLI on Ubuntu \/ Debian<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>First, install the required dependencies and add the GitHub CLI repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y curl gpg\n\nsudo mkdir -p -m 755 \/etc\/apt\/keyrings\ncurl -fsSL https:\/\/cli.github.com\/packages\/githubcli-archive-keyring.gpg | sudo tee \/etc\/apt\/keyrings\/githubcli-archive-keyring.gpg > \/dev\/null\nsudo chmod go+r \/etc\/apt\/keyrings\/githubcli-archive-keyring.gpg\n\necho \"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<\/code><\/pre>\n\n\n\n<p>Now update the package index and install the <code>gh<\/code> package:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install -y gh<\/code><\/pre>\n\n\n\n<p>Confirm the installation by checking the version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh --version<\/code><\/pre>\n\n\n\n<p>You should see output similar to:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh version 2.88.1 (2026-03-12)\nhttps:\/\/github.com\/cli\/cli\/releases\/tag\/v2.88.1<\/code><\/pre>\n\n\n\n<p>To upgrade GitHub CLI later, run a standard apt upgrade:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update && sudo apt upgrade gh<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Install GitHub CLI on RHEL \/ Rocky Linux \/ Fedora<\/h2>\n\n\n\n<p>For RPM-based distributions including RHEL 10, Rocky Linux 10, AlmaLinux 10, and Fedora 42, GitHub maintains a DNF\/YUM repository.<\/p>\n\n\n\n<p>Add the official GitHub CLI repository and install:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo dnf install -y 'dnf-command(config-manager)'\nsudo dnf config-manager addrepo --from-repofile=https:\/\/cli.github.com\/packages\/rpm\/gh-cli.repo\nsudo dnf install -y gh<\/code><\/pre>\n\n\n\n<p>On older RHEL\/CentOS systems that use <code>yum<\/code>, the commands are the same but use <code>yum<\/code> instead of <code>dnf<\/code>.<\/p>\n\n\n\n<p>Verify the installation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh --version<\/code><\/pre>\n\n\n\n<p>Expected output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh version 2.88.1 (2026-03-12)\nhttps:\/\/github.com\/cli\/cli\/releases\/tag\/v2.88.1<\/code><\/pre>\n\n\n\n<p>Future upgrades happen automatically through <code>dnf upgrade gh<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Install GitHub CLI on macOS<\/h2>\n\n\n\n<p>On macOS, the easiest way to install GitHub CLI is through <a href=\"https:\/\/brew.sh\/\" target=\"_blank\" rel=\"noopener\">Homebrew<\/a>. If you don&#8217;t have Homebrew installed, you can also download a binary from the <a href=\"https:\/\/github.com\/cli\/cli\/releases\" target=\"_blank\" rel=\"noopener\">GitHub CLI releases page<\/a>.<\/p>\n\n\n\n<p>Install using Homebrew:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>brew install gh<\/code><\/pre>\n\n\n\n<p>Verify the installed version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh --version<\/code><\/pre>\n\n\n\n<p>To upgrade later:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>brew upgrade gh<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Install GitHub CLI on Windows<\/h2>\n\n\n\n<p>On Windows, you can install GitHub CLI using either <strong>winget<\/strong> (built into Windows 11 and recent Windows 10 builds) or <strong>Chocolatey<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Option A: Install with winget<\/h3>\n\n\n\n<p>Open PowerShell or Command Prompt and run:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>winget install --id GitHub.cli<\/code><\/pre>\n\n\n\n<p>After installation, restart your terminal session so the <code>gh<\/code> command becomes available in your PATH.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Option B: Install with Chocolatey<\/h3>\n\n\n\n<p>If you use Chocolatey as your Windows package manager, install with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>choco install gh<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Option C: Install with Scoop<\/h3>\n\n\n\n<p>Scoop users can install GitHub CLI from the main bucket:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>scoop install gh<\/code><\/pre>\n\n\n\n<p>Regardless of installation method, verify by opening a new terminal and running:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh --version<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Authenticate with GitHub<\/h2>\n\n\n\n<p>After installing GitHub CLI, you need to authenticate before you can interact with GitHub. The <code>gh auth login<\/code> command walks you through an interactive flow.<\/p>\n\n\n\n<p>Start the authentication process:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh auth login<\/code><\/pre>\n\n\n\n<p>The CLI will prompt you to choose:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Where to authenticate<\/strong> &#8211; Choose GitHub.com or GitHub Enterprise Server<\/li>\n\n\n\n<li><strong>Preferred protocol<\/strong> &#8211; HTTPS or SSH<\/li>\n\n\n\n<li><strong>Authentication method<\/strong> &#8211; Browser-based login (recommended) or paste a personal access token<\/li>\n<\/ol>\n\n\n\n<p>For browser-based login, <code>gh<\/code> 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.<\/p>\n\n\n\n<p>Once authenticated, verify your login status:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh auth status<\/code><\/pre>\n\n\n\n<p>The output confirms which account is logged in and the active protocol:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>github.com\n  \u2713 Logged in to github.com account yourname (keyring)\n  - Active account: true\n  - Git operations protocol: https\n  - Token: gho_************************************\n  - Token scopes: 'gist', 'read:org', 'repo', 'workflow'<\/code><\/pre>\n\n\n\n<p>If you need to authenticate with a personal access token instead (useful for CI\/CD pipelines or automation), you can pass it directly:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"YOUR_TOKEN\" | gh auth login --with-token<\/code><\/pre>\n\n\n\n<p>To log out or switch accounts later:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh auth logout\ngh auth login<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Common gh CLI Usage<\/h2>\n\n\n\n<p>With GitHub CLI installed and authenticated, here are the most common workflows you will use daily. The <a href=\"https:\/\/cli.github.com\/manual\/\" target=\"_blank\" rel=\"noopener\">official gh CLI manual<\/a> covers every command in detail.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Working with Repositories<\/h3>\n\n\n\n<p>Clone a repository directly using the owner\/repo shorthand instead of typing full URLs:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh repo clone owner\/repository-name<\/code><\/pre>\n\n\n\n<p>Create a new repository interactively or with flags:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh repo create my-project --public --clone\ngh repo create my-private-app --private --clone<\/code><\/pre>\n\n\n\n<p>Fork and clone a repository in one step:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh repo fork owner\/repository-name --clone<\/code><\/pre>\n\n\n\n<p>View repository details from inside a cloned repo:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh repo view<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Managing Pull Requests<\/h3>\n\n\n\n<p>Pull request management is where <code>gh<\/code> saves the most time. You can create, review, merge, and check out PRs without leaving the terminal.<\/p>\n\n\n\n<p>Create a pull request from your current branch:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh pr create --title \"Add user authentication\" --body \"Implements JWT-based auth\"<\/code><\/pre>\n\n\n\n<p>List open pull requests in the current repository:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh pr list<\/code><\/pre>\n\n\n\n<p>Check out a pull request locally for testing:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh pr checkout 42<\/code><\/pre>\n\n\n\n<p>Review and merge a pull request:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh pr review 42 --approve\ngh pr merge 42 --squash<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Working with Issues<\/h3>\n\n\n\n<p>Create, list, and manage issues directly from the command line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh issue create --title \"Fix login timeout\" --body \"Login times out after 5 seconds on slow connections\"\ngh issue list\ngh issue view 15\ngh issue close 15<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Managing Gists<\/h3>\n\n\n\n<p>Create gists from files or standard input:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh gist create myfile.py --public --desc \"Python helper script\"\ngh gist list\ngh gist view GIST_ID<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Checking Workflow Runs<\/h3>\n\n\n\n<p>GitHub Actions workflows can be monitored and triggered from the CLI:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gh run list\ngh run view 123456789\ngh run watch 123456789\ngh workflow run deploy.yml<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Essential gh CLI Commands Reference<\/h2>\n\n\n\n<p>The table below summarizes the most commonly used GitHub CLI commands for quick reference.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>Command<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>gh auth login<\/code><\/td><td>Authenticate with GitHub<\/td><\/tr><tr><td><code>gh auth status<\/code><\/td><td>Check authentication status<\/td><\/tr><tr><td><code>gh repo clone owner\/repo<\/code><\/td><td>Clone a repository<\/td><\/tr><tr><td><code>gh repo create name<\/code><\/td><td>Create a new repository<\/td><\/tr><tr><td><code>gh repo fork owner\/repo<\/code><\/td><td>Fork a repository<\/td><\/tr><tr><td><code>gh pr create<\/code><\/td><td>Create a pull request<\/td><\/tr><tr><td><code>gh pr list<\/code><\/td><td>List open pull requests<\/td><\/tr><tr><td><code>gh pr checkout NUM<\/code><\/td><td>Check out a PR locally<\/td><\/tr><tr><td><code>gh pr merge NUM<\/code><\/td><td>Merge a pull request<\/td><\/tr><tr><td><code>gh pr diff NUM<\/code><\/td><td>View a PR diff in terminal<\/td><\/tr><tr><td><code>gh issue create<\/code><\/td><td>Create a new issue<\/td><\/tr><tr><td><code>gh issue list<\/code><\/td><td>List repository issues<\/td><\/tr><tr><td><code>gh issue close NUM<\/code><\/td><td>Close an issue<\/td><\/tr><tr><td><code>gh gist create FILE<\/code><\/td><td>Create a gist from a file<\/td><\/tr><tr><td><code>gh run list<\/code><\/td><td>List recent workflow runs<\/td><\/tr><tr><td><code>gh run watch NUM<\/code><\/td><td>Watch a workflow run live<\/td><\/tr><tr><td><code>gh workflow run FILE<\/code><\/td><td>Trigger a workflow manually<\/td><\/tr><tr><td><code>gh release create TAG<\/code><\/td><td>Create a new release<\/td><\/tr><tr><td><code>gh api ENDPOINT<\/code><\/td><td>Make authenticated API calls<\/td><\/tr><tr><td><code>gh ssh-key add FILE<\/code><\/td><td>Add an SSH key to your account<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>If you work with <a href=\"https:\/\/computingforgeeks.com\/how-to-install-visual-studio-code-on-ubuntu\/\" target=\"_blank\" rel=\"noopener\">Visual Studio Code<\/a> or any terminal-based editor, pairing it with <code>gh<\/code> gives you a fast, keyboard-driven development workflow. For auditing secrets in your repositories, consider using <a href=\"https:\/\/computingforgeeks.com\/gitleaks-audit-git-repos-for-secrets\/\" target=\"_blank\" rel=\"noopener\">Gitleaks to audit your Git repos<\/a>. If you are hosting your own Git service, check out our guides on installing <a href=\"https:\/\/computingforgeeks.com\/how-to-install-gitea-git-service-on-ubuntu\/\" target=\"_blank\" rel=\"noopener\">Gitea on Ubuntu<\/a> or <a href=\"https:\/\/computingforgeeks.com\/install-gitlab-ce-on-centos-fedora\/\" target=\"_blank\" rel=\"noopener\">GitLab CE on CentOS\/Fedora<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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, &#8230; <a title=\"Install GitHub CLI (gh) on Linux, macOS, and Windows\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/how-to-install-github-cli-on-linux-and-windows\/\" aria-label=\"Read more about Install GitHub CLI (gh) on Linux, macOS, and Windows\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":57466,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299,50,68],"tags":[1817],"class_list":["post-57388","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-linux-tutorials","category-programming","tag-github"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/57388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=57388"}],"version-history":[{"count":1,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/57388\/revisions"}],"predecessor-version":[{"id":163543,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/57388\/revisions\/163543"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/57466"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=57388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=57388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=57388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}