repobenchmarks // developer cli
CLI TOOLS
$ gh pr checkout 142 && gh pr diff

gh (Official GitHub CLI)

Brings pull requests, issues, releases, and GitHub Actions logs directly into your local terminal workflow without tab switching.

Language: Go Platforms: macOS, Linux, Windows Stars: >38,000
Local Terminal gh pr create gh run watch gh release create GitHub Cloud REST & GraphQL API Auth Token

Most developers spend hours every week switching back and forth between their code editor, terminal, and browser just to perform routine GitHub actions: creating pull requests, reading code review comments, checking why a CI pipeline failed, or drafting releases. The official GitHub CLI (gh) bridges this gap, allowing you to manage GitHub's full feature set directly from your command line.

5 Essential Everyday `gh` Workflows

1. Checking Out Pull Requests Locally in One Command

Instead of manually finding the remote fork URL, fetching the branch, and switching to it, simply run:

gh pr checkout 42

This automatically configures the upstream tracking branch, switches your working tree, and lets you immediately compile and test a colleague's PR.

2. Interactive Pull Request Creation

gh pr create --web    # Opens browser with prefilled branch and diff
gh pr create --fill   # Automatically uses commit messages for PR title & description

3. Real-Time CI Pipeline Monitoring

Instead of refreshing the GitHub Actions web tab to see if tests pass before merging, run:

gh run watch          # Live updates in your terminal as steps complete
gh run view --log-failed  # Immediately streams only failing test logs

4. Creating Binary Releases with Assets

gh release create v1.4.0 ./dist/* --generate-notes --title "Release v1.4.0"

Terminal PR Review Loop via `gh`

GitHub CLI Pull Request Review Workflow Shows checking out a PR, reviewing diffs locally, testing builds, and submitting reviews from the terminal. gh pr list Find pending PRs gh pr checkout 42 Pull code & branch gh pr diff Review changes gh pr review Approve or Comment

Supercharging `gh` with Extensions

The GitHub CLI includes a modular extension architecture. Developers can install community plugins using gh extension install <repo>. Two of the most useful extensions are:

  • dlvhdr/gh-dash: A rich, customizable terminal dashboard (built with Bubbletea) displaying your pull requests, issues, and notifications in side-by-side terminal panes.
  • github/gh-copilot: Query GitHub Copilot from the command line to generate explanations or suggest bash commands for obscure utilities.

Essential `gh` Commands Quick Reference

Task Command Primary Benefit
Clone Repo gh repo clone owner/repo Sets up authenticated HTTPS/SSH git remote automatically
Inspect CI Logs gh run view --log-failed Immediately isolates test failures without web navigation
Merge Pull Request gh pr merge --squash --delete-branch Squashes, merges, and purges remote/local branches cleanly
Raw API Query gh api repos/:owner/:repo/pulls Handles authentication headers and JSON formatting
⚠ Authentication Gotcha: Personal Access Token Scopes

When running gh auth login via web browser, the generated OAuth token grants standard repository permissions. However, if you plan to trigger manual workflows (gh workflow run) or inspect organization secrets, you must request elevated scopes using: gh auth refresh -s workflow,admin:org. Without these scopes, CI triggering commands will return generic HTTP 403: Resource not accessible by personal access token errors.

To install gh on your machine or browse full manual pages, visit the official site at cli.github.com or the open-source GitHub CLI repository.