What is GitHub CLI and Why You Actually Need It

GitHub CLI (gh) is the command-line tool that saves you from constantly switching between your terminal and GitHub's web interface. It's open source, free, and honestly one of the most useful developer tools GitHub has ever shipped.

GitHub CLI Terminal Interface

You're already living in your terminal anyway. You run git commands, execute tests, start dev servers. But the moment you need to create a PR or check why CI failed, you're alt-tabbing to your browser, clicking through GitHub's interface, then context-switching back to code. It's like trying to cook dinner while switching between your kitchen and the neighbor's house every 5 minutes.

What It Actually Does (And What Breaks)

GitHub CLI lets you create pull requests with gh pr create, check CI status with gh pr checks, and merge with gh pr merge - all without leaving terminal. The latest version is 2.78.0 from September 2024, and it's surprisingly solid for a GitHub product.

Pull requests: You can create them fast with `gh pr create`, but reviewing code diffs in the terminal sucks. Use it for quick operations, browser for actual code review. The `gh pr diff` output is harder to read than raw git diff, which is saying something.

Issues: `gh issue create` works great for quick bug reports. Assigning and labeling issues is smooth. The search functionality (`gh issue list`) is decent but GitHub's web search is still better for complex queries.

Actions: `gh run watch` is genuinely useful for watching CI/CD in real-time. Much better than refreshing the browser. But debugging failed workflows? You're back to the web interface because the CLI output is too minimal.

Authentication: The auth flow is decent but you'll probably need to re-auth every few months. `gh auth status` will lie to you sometimes - says you're authenticated but commands still fail with "Error: HTTP 401: Bad credentials (https://api.github.com)". When this happens, just run `gh auth login` again.

Terminal Command Line Interface

Real-World Performance Issues

GitHub CLI is fast for simple operations but has some gotchas:

  • Large repos take forever to clone with gh repo clone vs regular git clone (learned this the hard way trying to clone the Linux kernel repo - took 3x longer than standard git)
  • gh pr list times out on repos with thousands of PRs (our monorepo breaks it completely after 30 seconds)
  • JSON output format changes randomly between versions, so pin your CLI version in Docker images (some update around 2.75 broke all our deployment scripts)
  • The pagination on list commands is inconsistent - sometimes 30 items, sometimes 100, sometimes it just gives up and shows 5

CI/CD Automation

Automation Reality Check

Great for CI/CD scripts, but the JSON output format changes randomly between versions, so pin your CLI version in Docker images. Most teams use it for:

  • Automated PR creation from release scripts
  • CI status checks in deployment pipelines
  • Issue creation from monitoring alerts
  • Release automation (works well once set up)

Authentication in CI is straightforward with GITHUB_TOKEN, but GitHub Enterprise users get weird permissions issues that'll make you question your career choices. I spent an entire weekend debugging why Enterprise OAuth was rejecting valid tokens - turned out the admin had misconfigured the OAuth app and nobody bothered to document it.

The Truth About Alternatives

GitHub CLI killed the older Hub CLI (which was already half-broken). GitHub Desktop looks nice but falls apart faster than wet cardboard the moment you need anything beyond basic commits. Most serious developers end up using both GitHub CLI and the web interface - CLI for speed, web for detailed work.

It's free, which is weird for GitHub. Works fine with private repos and Enterprise Server, though Enterprise will make you hate your life for 2 days straight while you debug OAuth configurations that work about as well as a chocolate teapot.

Here's what actually breaks:

Frequently Asked Questions

Q

Why does `gh auth login` randomly stop working?

A

Authentication expires, usually without warning. When you get "Error: Resource not accessible by integration" or "Error: HTTP 401: Bad credentials", just run gh auth login again. It's not you, it's GitHub's token management. Happens more often if you switch between personal and work accounts.

Q

How do I fix "Resource not accessible by integration" errors?

A

This usually means your token lost permissions or expired. Try gh auth refresh first, then gh auth login --web if that doesn't work. For private repos, make sure you selected all the right scopes during auth

  • the default ones aren't always enough.
Q

Can I make it stop opening my browser every time?

A

Use gh auth login --with-token and paste a personal access token instead. Create one at github.com/settings/tokens with repo, workflow, and user permissions. Store it in a secure location because you'll need it again when it expires.

Q

Why is the diff output so damn hard to read?

A

gh pr diff output sucks compared to your normal git diff. The formatting is inconsistent and lacks syntax highlighting. Use gh pr view --web for actual code review, or stick with git diff origin/main locally.

Q

How do I check CI status without opening 50 browser tabs?

A

gh pr checks shows the status, but gh run watch is better for watching builds in real-time. Still limited compared to the web interface for debugging failures, but great for knowing when your tests pass.

Q

Does `gh pr create` work with templates?

A

It tries to use PR templates but often misses them or formats them weird. You'll end up manually fixing the description anyway. Use gh pr create --web if your team has detailed templates

  • it'll open the browser with everything pre-filled.
Q

Why does `gh repo clone` take forever on large repos?

A

It doesn't do shallow clones by default like some expect. Use git clone --depth 1 for faster clones on huge repos, then switch to gh commands for GitHub operations. The clone command is just a wrapper around git anyway. Took me 45 minutes to clone the Linux kernel repo before I figured this out the hard way.

Q

Can I use this with GitHub Enterprise without breaking everything?

A

Technically yes, but you're in for pain. Use gh auth login --hostname your-enterprise-url and pray your admin didn't completely screw the OAuth config. Enterprise permissions are more finicky than a toddler at dinnertime, so you'll waste entire afternoons debugging auth nonsense that works perfectly on github.com.

Q

How do I fix "api rate limit exceeded" errors?

A

You're probably hitting the API too hard with scripts. GitHub CLI shares your personal rate limits (5,000/hour). Use --limit flags on list commands and add delays in loops. Enterprise users get higher limits but still hit them with aggressive automation. Learn this before you get "Error: API rate limit exceeded for user" at 2am when your deployment script fails.

GitHub CLI vs Alternatives - Real World Comparison

Feature

GitHub CLI

Git

GitHub Desktop

Hub CLI

Reality Check

Actually useful

Essential

GitHub Desktop looks pretty but it's for people who are afraid of terminals

Dead, don't use

What It's Good At

Quick GitHub operations

Version control

Git for beginners

Nothing anymore

What It Sucks At

Code review UI, large repos

GitHub features

Anything complex

Everything (deprecated)

Learning Curve

30 minutes if you know git

Months to master

5 minutes

Why bother?

Performance

Fast for simple ops, slow for big repos

Consistently fast

Slow on large repos

Unmaintained

Automation

Great JSON support

Shell scripting only

None

Was okay

Platform Quirks

Auth breaks on Windows WSL sometimes

Just works

macOS only really

Linux install was painful

Enterprise Pain Level

Medium (auth issues)

None

High (limited features)

High (abandoned)

Installation and Getting Started

Package Installation

Installation Reality Check

macOS: `brew install gh` works fine most of the time. ARM Macs (M1/M2) should get the right version automatically, but double-check with `gh --version`. If you downloaded the Intel version by mistake, it'll work but be slower.

Windows: `winget install --id GitHub.cli` is your best bet if you're on Windows 10/11. Chocolatey works too (choco install gh) but sometimes lags behind on versions. The MSI installer is fine but you'll have to manually update it. If you're using WSL2, install the Linux version inside WSL instead of the Windows version - it avoids auth weirdness.

Linux: Package managers work but often have old versions. Ubuntu/Debian users can add GitHub's APT repo for current releases. Otherwise grab the binary and throw it in /usr/local/bin.

Security Authentication

Authentication (Where Everything Goes Wrong)

Run gh auth login and prepare for 10 minutes of OAuth hell. The web browser flow usually works, but:

  • Browser flow: Opens GitHub, you click authorize, browser shows "success" but CLI throws "Error: authentication failed" anyway. Happens about 20% of the time because OAuth is apparently held together with duct tape and wishful thinking. Just run gh auth login again.
  • Personal access token: More reliable but requires creating tokens at github.com/settings/tokens. Make sure you select repo, workflow, and user scopes or you'll get permission errors later.
  • SSH keys: Works if you already have SSH set up with GitHub, but pointless since you still need HTTPS auth for the API calls.

Windows WSL2 users: The browser redirect often breaks. Use gh auth login --with-token and paste a PAT instead.

GitHub Enterprise users: Use gh auth login --hostname your-github-enterprise-url and expect additional pain. Your admin probably didn't configure OAuth apps properly.

Git Repository Management

Commands That Actually Work

Repository stuff: `gh repo clone` is just a wrapper around git clone but shows you fork info. `gh repo create` is genuinely useful for making new repos without clicking through GitHub's UI. `gh repo view` shows README content in your terminal which is... fine.

Pull requests: gh pr create saves time but always double-check the branch and title before submitting. gh pr list shows your PRs quickly. gh pr merge works but web interface is better for reviewing the actual changes first. gh pr checks is clutch for CI status.

Issues: gh issue create is fast for bug reports. gh issue list is good with filters like --assignee @me or --state open. The search isn't as good as GitHub's web search for finding old issues.

Team Collaboration

Team Adoption (The Hard Way)

Getting a team to use GitHub CLI is like herding cats. Some devs love it, others prefer clicking through the web interface.

What works for teams:

  • Use it in CI/CD scripts for creating releases and updating PRs
  • Standard workflow scripts that create PRs with proper templates
  • Checking build status without opening browsers
  • Issue creation from monitoring alerts

What doesn't work:

  • Forcing everyone to use it for code review (web interface is better)
  • Expecting perfect consistency across different machines (auth breaks randomly)
  • Using it for complex GitHub admin tasks (permissions, teams, etc.)

Enterprise gotchas: Enterprise Server is where GitHub CLI goes to die a slow, painful death. Different API endpoints, bizarre rate limits, and auth so fragile it shatters if you breathe on it funny. I once burned 6 hours debugging why gh pr create worked fine on my laptop but threw "Error: Resource not accessible by integration" in CI - turns out our admin had configured the OAuth app while apparently drunk, and nobody documented the weird token requirements.

JSON output is solid for scripting once you figure out the structure, but it changes between versions so pin your CLI version in Docker images.

That's the setup. Next up: where to find help when this inevitably breaks.

Related Tools & Recommendations

howto
Similar content

Install GitHub CLI: A Step-by-Step Setup Guide

Tired of alt-tabbing between terminal and GitHub? Get gh working so you can stop clicking through web interfaces

GitHub CLI
/howto/github-cli-install/complete-setup-guide
100%
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
80%
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
50%
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
50%
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
38%
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
38%
tool
Recommended

GitHub Actions Security Hardening - Prevent Supply Chain Attacks

integrates with GitHub Actions

GitHub Actions
/tool/github-actions/security-hardening
35%
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
35%
tool
Recommended

GitHub Actions - CI/CD That Actually Lives Inside GitHub

integrates with GitHub Actions

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

GitHub Codespaces Enterprise Deployment - Complete Cost & Management Guide

integrates with GitHub Codespaces

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

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

integrates with GitHub Codespaces

GitHub Codespaces
/tool/github-codespaces/troubleshooting-gotchas
35%
tool
Recommended

GitHub Codespaces - Cloud Dev Environments That Actually Work

integrates with GitHub Codespaces

GitHub Codespaces
/tool/github-codespaces/overview
35%
news
Popular choice

Anthropic Raises $13B at $183B Valuation: AI Bubble Peak or Actual Revenue?

Another AI funding round that makes no sense - $183 billion for a chatbot company that burns through investor money faster than AWS bills in a misconfigured k8s

/news/2025-09-02/anthropic-funding-surge
32%
tool
Popular choice

Node.js Performance Optimization - Stop Your App From Being Embarrassingly Slow

Master Node.js performance optimization techniques. Learn to speed up your V8 engine, effectively use clustering & worker threads, and scale your applications e

Node.js
/tool/node.js/performance-optimization
30%
news
Popular choice

Anthropic Hits $183B Valuation - More Than Most Countries

Claude maker raises $13B as AI bubble reaches peak absurdity

/news/2025-09-03/anthropic-183b-valuation
29%
review
Recommended

I Got Sick of Editor Wars Without Data, So I Tested the Shit Out of Zed vs VS Code vs Cursor

30 Days of Actually Using These Things - Here's What Actually Matters

Zed
/review/zed-vs-vscode-vs-cursor/performance-benchmark-review
29%
news
Recommended

VS Code 1.103 Finally Fixes the MCP Server Restart Hell

Microsoft just solved one of the most annoying problems in AI-powered development - manually restarting MCP servers every damn time

Technology News Aggregation
/news/2025-08-26/vscode-mcp-auto-start
29%
alternatives
Recommended

Terraform Alternatives That Don't Suck to Migrate To

Stop paying HashiCorp's ransom and actually keep your infrastructure working

Terraform
/alternatives/terraform/migration-friendly-alternatives
29%
pricing
Recommended

Infrastructure as Code Pricing Reality Check: Terraform vs Pulumi vs CloudFormation

What these IaC tools actually cost you in 2025 - and why your AWS bill might double

Terraform
/pricing/terraform-pulumi-cloudformation/infrastructure-as-code-cost-analysis
29%
tool
Recommended

Terraform - Define Infrastructure in Code Instead of Clicking Through AWS Console for 3 Hours

The tool that lets you describe what you want instead of how to build it (assuming you enjoy YAML's evil twin)

Terraform
/tool/terraform/overview
29%

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