GitHub CLI (gh) is the official command-line tool for interacting with GitHub from your terminal, enabling repository management, issue tracking, pull request workflows, and GitHub Actions operations without leaving the command line. It eliminates context switching by bringing GitHub's web features directly to developers' terminals, supporting automation through scripting and integration with CI/CD pipelines. Unlike Git (which manages version control), GitHub CLI specifically handles GitHub platform features — issues, PRs, releases, gists, actions, and API access — while seamlessly integrating with Git workflows to provide a complete development experience from the terminal.
What This Cheat Sheet Covers
This topic spans 18 focused tables and 179 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Installation and Authentication
Everything in gh starts with proving who you are. These commands cover the full lifecycle of an authenticated session — signing in through the browser or a token, checking which account is active, juggling multiple personal and work logins, and pointing gh at GitHub Enterprise instead of github.com. The environment-variable approach is the one to remember for CI/CD, where there's no human to click through a login prompt.
| Command | Example | Description |
|---|---|---|
gh auth login | • Authenticate with GitHub interactively via browser or token • prompts for GitHub.com or Enterprise • stores credentials securely | |
gh auth status | • Display currently authenticated accounts and token scopes • shows which user is logged in • useful for verifying authentication state | |
gh auth token | • Print the authentication token for the active account • outputs token to stdout • useful for scripting or debugging | |
gh auth refresh -s project | • Add additional OAuth scopes to existing token • re-authenticates to request expanded permissions • required for projects, gists, or codespaces | |
gh auth switch | • Switch between multiple authenticated accounts interactively • useful for managing personal + work accounts |