What is GitHub CLI?
The GitHub CLI (command‑line interface), distributed as gh, is an official tool that brings GitHub’s core features into the terminal. It enables developers to interact with repositories, issues, pull requests, releases, and more without leaving the command line.
How to Install and Configure GitHub CLI
Installation varies by operating system. Follow the steps that match your environment:
- macOS: run brew install gh using Homebrew.
- Linux: use the package manager (apt, dnf, yum) or download the binary from GitHub releases. Example for Debian/Ubuntu: sudo apt install gh.
- Windows: install via winget install --id GitHub.cli or download the MSI installer.
After installation, authenticate the CLI with your GitHub account:
- Run gh auth login.
- Select GitHub.com or GitHub Enterprise.
- Choose HTTPS or SSH authentication.
- Complete the interactive prompt to store the token.
How to Use GitHub CLI – Core Commands
Below are the most common command groups and examples:
- Repository Management: gh repo clone OWNER/REPO to clone a repository; gh repo create to create a new repository from the terminal.
- Issues and Pull Requests: gh issue list to list open issues; gh issue create to open a new issue; gh pr checkout 42 to check out pull request #42; gh pr merge --merge to merge the current PR.
- Workflow Automation: gh run list to list recent GitHub Actions runs; gh run watch to stream live logs of a workflow.
- Release Management: gh release create v1.0.0 to draft a new release; gh release upload v1.0.0 ./binary.tar.gz to attach assets.
Why Use GitHub CLI?
Adopting the GitHub CLI offers several advantages:
- Speed – perform GitHub operations without switching to a web browser, reducing context‑switching.
- Automation – script repetitive tasks in CI pipelines or local scripts using standard shell commands.
- Consistency – use the same interface across macOS, Linux, and Windows, ensuring a uniform workflow.
- Enhanced Productivity – combine gh with other CLI tools for powerful, interactive experiences.