How to install GitHub CLI (gh) and sign in
By Pull This RepoPosted 4 min read
Short answer
To install GitHub CLI, run winget install --id GitHub.cli --source winget on Windows, brew install gh on a Mac, or add GitHub's apt or dnf repo on Linux and install the gh package. Then run gh auth login, choose GitHub.com, and finish the sign-in in your browser. gh stores the token in your system's credential store.
GitHub CLI, the gh command, lets you sign in to GitHub once and then clone repos, check out pull requests and download releases from your terminal. To install gh CLI you use your system's normal package manager: winget on Windows, Homebrew on a Mac, and GitHub's own apt or dnf repo on Linux. This guide gives the exact commands for each, then walks through gh auth login and three commands worth knowing. Everything was checked against the cli/cli install docs and the GitHub CLI manual on 22 November 2026.
The repo, cli/cli, is MIT licensed, had 47,132 stars on GitHub on 22 November 2026, and released v2.105.0 on 18 November 2026. Its README says gh supports macOS, Windows and Linux.
How do you install GitHub CLI on Windows?
Use winget, the official route in the cli/cli Windows guide:
winget install --id GitHub.cli --source wingetThen close Windows Terminal and open a new window. The install guide says the installer modifies your PATH, and a new tab is not enough for the change to take effect.
To upgrade later:
winget upgrade --id GitHub.cli --source wingetNo winget? The Releases page has .exe and .msi installers for 386, amd64 and arm64. The guide also lists Chocolatey (choco install gh) as a community package that the GitHub CLI team does not maintain.
How do you install GitHub CLI on a Mac?
Use Homebrew:
brew install gh
brew upgrade gh # later, to updateThe macOS guide says the formula is supported by the GitHub CLI maintainers with help from Homebrew. If you do not have Homebrew yet, our guide on how to install Homebrew covers the install and the PATH step. The Releases page also has a universal installer, though the macOS guide notes its .pkg installers are unsigned.
How do you install GitHub CLI on Ubuntu or Debian?
Add GitHub's apt repo and install gh. This is the official command block from the Linux install guide, run as one paste:
(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 -yIt installs wget if needed, saves GitHub's signing key, adds the repo, then installs gh. To upgrade:
sudo apt update
sudo apt install ghThe guide says these packages cover Debian, Ubuntu and Raspberry Pi. It also lists the signing key fingerprints at the top of the page; GitHub rotated the key for its Linux repos effective 5 September 2026, which the README flags with a link to fixes.
How do you install GitHub CLI on Fedora?
Add the repo file with dnf, then install. For DNF5, the guide gives:
sudo dnf install dnf5-plugins
sudo dnf config-manager addrepo --from-repofile=https://cli.github.com/packages/rpm/gh-cli.repo
sudo dnf install ghUpdate later with sudo dnf update gh. The guide has separate DNF4 commands, and the same RPM repo covers Amazon Linux 2, CentOS, RHEL, openSUSE and SUSE.
How do you sign in with gh auth login?
Run it and answer the prompts:
gh auth loginYou choose the host (GitHub.com for most people), whether Git should use HTTPS or SSH, and how to authenticate. The manual says the default is "a web-based browser flow": gh sends you to GitHub in your browser to approve the sign-in. Afterwards the token is "stored securely in the system credential store." If no store is available, gh falls back to a plain text file.
Check it worked:
gh auth statusUseful variants from the manual:
# set the Git protocol up front
gh auth login --git-protocol https
# sign in with a token read from a file
gh auth login --with-token < mytoken.txtA classic token passed to --with-token needs at least the repo, read:org and gist scopes. For fine-grained tokens, the manual says to favour setting GH_TOKEN instead.
What can you do with gh once it is installed?
Three commands cover most of what people install it for.
Clone a repo by owner and name. No URL to copy, and leave out the owner to clone one of your own repos:
gh repo clone OWNER/REPOIf the repo is a fork, the manual says gh adds the parent as a second remote called upstream. Extra git clone flags, such as --depth=1 for a shallow copy, go at the end after a separator of two hyphens, as the manual's example shows. Our guide on how to clone a GitHub repo compares this with every other clone method, including private repos.
Check out a pull request. Test someone's change locally by number, URL or branch:
gh pr checkout 32Run gh pr checkout with no number to pick from the 10 most recent pull requests.
Download release files. Grab the installers from a repo's latest release without opening a browser:
gh release download --repo OWNER/REPO --pattern '*.deb'--pattern takes a glob and can be repeated, --dir picks the folder, and --archive=zip downloads the source code archive instead. Add a tag such as v1.2.3 after download for a specific release.
What is the catch?
gh is a terminal tool, so it does not replace a visual Git app; on Linux, where GitHub ships no desktop app, see our page on GitHub Desktop on Linux for the community build. The manual notes that if your system has no credential store, the token lands in a plain text file, so check gh auth status on a shared or minimal Linux machine. And gh works alongside Git rather than replacing it: the manual describes gh repo clone as passing flags through to git clone, so install Git first with our guide on how to install Git.
Running your own CI machine? See how to set up a GitHub self-hosted runner.
Pull it. Stash it.
Questions people ask
How do I install GitHub CLI on Windows?
Open PowerShell or Windows Terminal and run winget install --id GitHub.cli --source winget. The installer changes your PATH, so close Windows Terminal and open a new window, not just a new tab, before you type gh. The Releases page also has exe and msi installers.
What does gh auth login do?
It signs gh in to your GitHub account. By default it opens a browser flow, then stores the token in your system credential store, or in a plain text file if no store is available. It also asks whether Git should use HTTPS or SSH for this host.
Can I sign in to gh with a token instead of the browser?
Yes. Pipe a classic personal access token into gh auth login --with-token. The gh manual says it needs at least the repo, read:org and gist scopes. For a fine-grained token, the manual recommends setting the GH_TOKEN environment variable instead.
Is GitHub CLI free?
Yes. GitHub CLI is free and open source under the MIT licence. Its repo, cli/cli, had 47,132 stars on GitHub on 22 November 2026, and its latest release was v2.105.0, published on 18 November 2026.
Why does apt fail to update gh after September 2026?
GitHub rotated the PGP key that signs its Linux package repos, effective 5 September 2026. The cli/cli README links an announcement with fixes. Its Linux install guide lists the current key fingerprints so you can check the key you have.
Sources
- 1cli/cli README (read 2026-11-22)
- 2cli/cli: Installing gh on Windows (read 2026-11-22)
- 3cli/cli: Installing gh on macOS (read 2026-11-22)
- 4cli/cli: Installing gh on Linux and BSD (read 2026-11-22)
- 5GitHub CLI manual: gh auth login (read 2026-11-22)
- 6GitHub CLI manual: gh pr checkout (read 2026-11-22)
- 7GitHub CLI manual: gh release download (read 2026-11-22)
- 8GitHub CLI manual: gh repo clone (read 2026-11-22)
More repos like this
Get tomorrow's repo in your feed
One free, open source repo a day as a short video, shown working, with the catch named. Pull it. Stash it.
