Why Install GitHub CLI?

Look, we've all been there. You're deep in terminal work, need to create a PR, and suddenly you're clicking through GitHub's web interface like some kind of peasant. GitHub CLI fixes this shit.

GitHub CLI (the gh command) lets you do GitHub stuff without leaving your terminal. It's been around since 2020, has 40.5k GitHub stars, and actually works unlike most CLI tools that promise the moon.

Prerequisites (the boring stuff)

  • GitHub account (obviously)
  • Terminal access (duh)
  • Admin rights to install stuff

What you actually get

  • Create PRs from terminal: gh pr create
  • Clone repos fast: gh repo clone owner/repo
  • Check CI status: gh pr checks
  • Create issues: gh issue create
  • Browse repos: gh repo view

Installation should take 5 minutes but Windows will definitely find new ways to fuck this up. Authentication is where most people get stuck because OAuth flows are garbage half the time, but we'll get through it.

The official CLI docs are decent but dry as hell. The GitHub CLI repo has better examples if you need to see real usage. Works with GitHub Enterprise too, assuming your IT department isn't running something ancient.

Real talk on timing

When you get stuck, check these

Installation Methods by Platform

Platform

Recommended Method

Command

Alternative Methods

macOS

Homebrew

brew install gh

MacPorts, Conda, Binary

Windows

Winget

winget install --id GitHub.cli

Chocolatey, Scoop, MSI Installer

Ubuntu/Debian

APT Repository

sudo apt install gh

DEB Package, Snap

Fedora/RHEL

DNF

sudo dnf install gh

RPM Package

Arch Linux

Pacman

sudo pacman -S github-cli

AUR, Binary

Step-by-Step Installation Process

GitHub CLI in action
GitHub CLI brings your workflow to the terminal

Windows Installation (Prepare for Pain)

Windows Terminal
Windows Terminal - where your GitHub CLI will live

Method 1: Winget (If You're Lucky)

## First check if Windows actually has winget installed
winget --version

## If that worked, try this:
winget install --id GitHub.cli

If winget gives you grief (and it will), you'll get errors like "Failed to install package" or "Package not found" or my personal favorite, "This app could not be installed" with zero explanation. Just move on to chocolatey.

Method 2: Chocolatey (The Reliable One)

Chocolatey Logo

## Install chocolatey if you haven't already (check chocolatey.org)
choco install gh

Chocolatey works better than winget but installs extra crap sometimes. If you see warnings about dependencies, just let it install them. They're probably important.

Method 3: Manual MSI (When All Else Fails)

  1. Go to GitHub CLI releases
  2. Download the .msi file for Windows
  3. Run as administrator (Windows will definitely ask for this)
  4. Click through the installer like it's 1999

The MSI route always works but you'll have to update manually. Pain in the ass but at least it's predictable.

macOS Installation (Actually Works)

Method 1: Homebrew (The Right Way)

## If you don't have homebrew yet, get it first
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

## Install GitHub CLI - this actually works reliably
brew install gh

## Check it worked
gh --version

Homebrew on macOS is like apt on Linux - it just works. If you're on Apple Silicon (M1/M2/etc), homebrew handles the architecture automatically. No bullshit.

Method 2: MacPorts (Why Though?)

sudo port install gh

MacPorts exists but nobody uses it anymore. Stick with homebrew unless you enjoy pain.

Linux Installation (Distribution Hell)

Bash Shell
Bash - your Linux terminal of choice

Ubuntu/Debian - The Long Way

Ubuntu Logo

The official repository method involves adding GPG keys and custom sources - it's complicated as hell and breaks on WSL2 about 60% of the time. Skip the nightmare and just download the .deb file from GitHub releases and install it like a normal person:

## Much easier
wget https://github.com/cli/cli/releases/download/v2.78.0/gh_2.78.0_linux_amd64.deb
sudo dpkg -i gh_2.78.0_linux_amd64.deb

Fedora/RHEL - Actually Simple

sudo dnf install gh

This just works. Fedora/RHEL got their shit together.

Arch Linux - Obviously

sudo pacman -S github-cli

Arch users already know this. If you're using Arch, you probably compiled it from source already.

Verification (Did It Actually Work?)

## Check if it installed
gh --version

You should see something like gh version 2.78.0. If you get "command not found", restart your terminal first (Windows users especially). On Windows 11, you might need to restart the entire terminal app, not just close the tab because Microsoft's PATH updating is broken. Still nothing? The install failed - check PATH or try a different install method.

Authentication (Where Everyone Gets Stuck)

Security Key
Authentication - the step that breaks everything

Interactive Login (Usually Works)

gh auth login

This opens your browser and does OAuth. It's the path of least resistance:

  1. Pick GitHub.com (unless you're corporate)
  2. Choose HTTPS (SSH is fine but HTTPS has fewer problems)
  3. Let it open your browser and click allow
  4. Come back to terminal, should say "Logged in as..."

Token Login (When Browser Auth Fails)
The browser flow fails on headless servers, WSL2 networking weirdness, corporate firewalls, or if your company has ridiculous proxy settings. Make a personal access token instead:

## Set it as environment variable
export GITHUB_TOKEN=ghp_your_token_here

## Or pipe it in
echo "ghp_your_token_here" | gh auth login --with-token

Test It Works

## Check login status
gh auth status

## Try listing your repos - should work without browser
gh repo list

If gh auth status shows you're logged in but commands fail with 404s, your token doesn't have enough permissions. Go back to GitHub settings and give it more scopes.

If things go sideways:

FAQ for Real Problems People Actually Have

Q

"Command not found" after installing - WTF?

A

Restart your terminal. Seriously. Most installers don't update your current terminal session's PATH. On Windows, you might need to restart the entire terminal app, not just close the tab.Still broken? Check if it's actually installed:

  • Windows: where gh
  • macOS/Linux: which gh
    If that returns nothing, the installation failed. Try a different method.
Q

What's the difference between git and gh?

A

git does Git stuff (commits, branches, pushing code). gh does GitHub stuff (PRs, issues, releases). You need both. Think of gh as the web interface stuff you can now do in terminal.

Q

Why does gh auth login open my browser but nothing happens?

A

Your corporate firewall is blocking the OAuth redirect, or you're on WSL2 where browser integration is held together with duct tape. Make a personal access token instead:

export GITHUB_TOKEN=your_token_here
gh auth status

This is better for servers, WSL2, or if your company's proxy blocks OAuth flows because IT departments love making everything complicated.

Q

Does this work with GitHub Enterprise?

A

Yeah, use gh auth login --hostname your-enterprise-url.com. Works with GitHub Enterprise Server 2.20+. If your company uses older versions, complain to your IT department.

Q

How do I update this thing?

A

Same way you installed it:

  • Homebrew: brew upgrade gh
  • Chocolatey: choco upgrade gh
  • Winget: winget upgrade GitHub.cli
  • Manual install: download new version and install over the old one
Q

"Permission denied" errors during install

A

You need admin/sudo. On Windows, right-click Command Prompt and "Run as Administrator". On Mac/Linux, use sudo with your install commands.

Q

Can I use this with my company's weird enterprise setup?

A

Maybe. If your IT department is competent, yes. If they're running GitHub Enterprise Server 2.19 or older, you're screwed. Use gh auth login --hostname your-enterprise-url.com and pray.

Q

Multiple GitHub accounts (work vs personal)

A

Use gh auth login --hostname github.com and gh auth login --hostname github-enterprise.com for different accounts. Switch with gh auth switch. Works better than trying to juggle SSH keys for different accounts.

Q

What token permissions do I need?

A

Start with repo, user, read:org. GitHub CLI will tell you when it needs more permissions. Don't give it everything upfront

  • that's a security risk.
Q

Why does gh say "Resource not accessible by personal access token"?

A

Your token doesn't have enough permissions, or you're trying to access a private org repo. Go back to GitHub settings and add more scopes. If you're still getting errors, you might need admin approval for org access because enterprise security policies are the worst.

GitHub CLI (gh) - How to manage repositories more efficiently by AI & DevOps Toolkit

This 15-minute tutorial covers installation and setup. It's from the GitHub team so they actually know what they're talking about, unlike most YouTube tutorials where some guy with a gaming chair explains basic concepts for 45 minutes.

What's covered:
- Installing on Windows, Mac, Linux (the basics)
- Authentication (where most people get stuck)
- Essential commands to actually use the thing
- How it works with git (spoiler: fine)

Why watch this: At least they show real terminal output instead of fake demo environments like most tutorial garbage. They don't waste time explaining what GitHub is or why you might want to use version control.

📺 YouTube

Related Tools & Recommendations

tool
Recommended

GitHub Copilot - AI Pair Programming That Actually Works

Stop copy-pasting from ChatGPT like a caveman - this thing lives inside your editor

GitHub Copilot
/tool/github-copilot/overview
100%
howto
Recommended

Undo Git Commits While Keeping Your Changes

Committed too early and now you're fucked? Here's how to unfuck yourself without losing two weeks of work

Git
/howto/undo-git-commit-keep-changes/complete-undo-guide
62%
howto
Recommended

SSH Multiple Git Accounts - Stop Fucking Up Your Identity

Git asking for passwords every goddamn time? Personal furry fanfiction commits accidentally pushed to your company repo?

Git
/howto/configure-git-multiple-accounts/ssh-based-configuration
62%
howto
Similar content

Install Node.js & NVM on Mac M1/M2/M3: A Complete Guide

My M1 Mac setup broke at 2am before a deployment. Here's how I fixed it so you don't have to suffer.

Node Version Manager (NVM)
/howto/install-nodejs-nvm-mac-m1/complete-installation-guide
62%
troubleshoot
Similar content

Git Fatal Not a Git Repository - Fix It in Under 5 Minutes

When Git decides to fuck your deployment at 2am

Git
/troubleshoot/git-fatal-not-a-git-repository/common-errors-solutions
56%
howto
Similar content

Configure Cursor AI Custom Prompts: A Complete Setup Guide

Stop fighting with Cursor's confusing configuration mess and get it working for your actual development needs in under 30 minutes.

Cursor
/howto/configure-cursor-ai-custom-prompts/complete-configuration-guide
56%
howto
Similar content

Git: How to Merge Specific Files from Another Branch

November 15th, 2023, 11:47 PM: Production is fucked. You need the bug fix from the feature branch. You do NOT need the 47 experimental commits that Jim pushed a

Git
/howto/merge-git-branch-specific-files/selective-file-merge-guide
56%
howto
Similar content

Mastering ML Model Deployment: From Jupyter to Production

Tired of "it works on my machine" but crashes with real users? Here's what actually works.

Docker
/howto/deploy-machine-learning-models-to-production/production-deployment-guide
54%
howto
Similar content

GitHub Copilot JetBrains IDE: Complete Setup & Troubleshooting

Stop fighting with code completion and let AI do the heavy lifting in IntelliJ, PyCharm, WebStorm, or whatever JetBrains IDE you're using

GitHub Copilot
/howto/setup-github-copilot-jetbrains-ide/complete-setup-guide
52%
howto
Similar content

API Rate Limiting: Complete Implementation Guide & Best Practices

Because your servers have better things to do than serve malicious bots all day

Redis
/howto/implement-api-rate-limiting/complete-setup-guide
50%
tool
Similar content

Kibana - Because Raw Elasticsearch JSON Makes Your Eyes Bleed

Stop manually parsing Elasticsearch responses and build dashboards that actually help debug production issues.

Kibana
/tool/kibana/overview
48%
compare
Recommended

I Tested 4 AI Coding Tools So You Don't Have To

Here's what actually works and what broke my workflow

Cursor
/compare/cursor/github-copilot/claude-code/windsurf/codeium/comprehensive-ai-coding-assistant-comparison
48%
alternatives
Recommended

GitHub Copilot Alternatives - Stop Getting Screwed by Microsoft

Copilot's gotten expensive as hell and slow as shit. Here's what actually works better.

GitHub Copilot
/alternatives/github-copilot/enterprise-migration
48%
troubleshoot
Similar content

Fix MySQL Error 1045 Access Denied: Solutions & Troubleshooting

Stop fucking around with generic fixes - these authentication solutions are tested on thousands of production systems

MySQL
/troubleshoot/mysql-error-1045-access-denied/authentication-error-solutions
44%
tool
Similar content

Open Policy Agent (OPA): Centralize Authorization & Policy Management

Stop hardcoding "if user.role == admin" across 47 microservices - ask OPA instead

/tool/open-policy-agent/overview
44%
tool
Recommended

GitHub Actions Security Hardening - Prevent Supply Chain Attacks

integrates with GitHub Actions

GitHub Actions
/tool/github-actions/security-hardening
43%
alternatives
Recommended

Tired of GitHub Actions Eating Your Budget? Here's Where Teams Are Actually Going

integrates with GitHub Actions

GitHub Actions
/alternatives/github-actions/migration-ready-alternatives
43%
tool
Recommended

GitHub Actions - CI/CD That Actually Lives Inside GitHub

integrates with GitHub Actions

GitHub Actions
/tool/github-actions/overview
43%
tool
Recommended

GitHub Codespaces Enterprise Deployment - Complete Cost & Management Guide

integrates with GitHub Codespaces

GitHub Codespaces
/tool/github-codespaces/enterprise-deployment-cost-optimization
43%
tool
Recommended

GitHub Codespaces - When Shit Goes Wrong (And How to Fix It)

integrates with GitHub Codespaces

GitHub Codespaces
/tool/github-codespaces/troubleshooting-gotchas
43%

Recommendations combine user behavior, content similarity, research intelligence, and SEO optimization