How We Use GitHub CLI

Using the gh command-line tool for faster GitHub workflows

How We Use GitHub CLI

The GitHub CLI (gh) lets you work with GitHub directly from your terminal. No switching to the browser - create PRs, check issues, and manage repos without leaving your workflow.

Core idea: Stay in flow. The terminal is where you code, so it's where you should manage code too.

Why Use GitHub CLI?

TaskBrowser WayCLI Way
Create PROpen browser → Navigate → Click buttons → Fill formgh pr create
Check PR statusOpen browser → Find PR → Readgh pr status
View issueOpen browser → Navigate to issuesgh issue view 123

Time saved: Seconds add up. More importantly, you stay focused.

Installation

# macOS
brew install gh

# Windows (Chocolatey)
choco install gh

# Windows (Winget)
winget install GitHub.cli

After installing, authenticate:

gh auth login

Follow the prompts to connect your GitHub account.

Essential Commands

Pull Requests

# Create a PR (interactive)
gh pr create

# Create PR with title and body
gh pr create --title "Add keyword export" --body "Exports results to CSV"

# Create PR and fill from commit messages
gh pr create --fill

# View your PRs
gh pr status

# View a specific PR
gh pr view 123

# Check out a PR locally
gh pr checkout 123

# Merge a PR
gh pr merge 123

# Close a PR
gh pr close 123

Issues

# Create an issue (interactive)
gh issue create

# Create issue with title
gh issue create --title "Bug: Export fails for large datasets"

# List open issues
gh issue list

# View an issue
gh issue view 123

# Close an issue
gh issue close 123

# Reopen an issue
gh issue reopen 123

Repository

# Clone a repo
gh repo clone owner/repo

# Create a new repo
gh repo create my-project

# View repo in browser
gh repo view --web

# Fork a repo
gh repo fork owner/repo

Workflow (GitHub Actions)

# List workflow runs
gh run list

# View a specific run
gh run view 123

# Watch a run in progress
gh run watch

# Rerun a failed workflow
gh run rerun 123

Daily Workflow with CLI

Starting a Feature

# Get latest main
git checkout main && git pull

# Create feature branch
git checkout -b feature/keyword-export

# ... make changes ...

# Push and create PR in one step
git push -u origin feature/keyword-export
gh pr create --fill

Reviewing a PR

# See what needs review
gh pr status

# Check out the PR to test locally
gh pr checkout 123

# After testing, approve
gh pr review 123 --approve

# Or request changes
gh pr review 123 --request-changes --body "Need to handle empty datasets"

Quick Issue Triage

# See open issues
gh issue list

# Add a label
gh issue edit 123 --add-label "bug"

# Assign to yourself
gh issue edit 123 --add-assignee @me

# Close with comment
gh issue close 123 --comment "Fixed in PR #456"

Useful Aliases

Add these to your shell config for even faster workflows:

# Create PR quickly
alias gpr="gh pr create --fill"

# Check PR status
alias gprs="gh pr status"

# List my PRs
alias gprl="gh pr list --author @me"

# View current PR in browser
alias gprv="gh pr view --web"

When to Use CLI vs Browser

Use CLIUse Browser
Creating PRsComplex PR reviews with many files
Quick status checksReading long discussions
Routine operationsManaging project boards
Scripting/automationFirst-time repo setup

Quick Reference

I want to...Command
Create a PRgh pr create
See my PRsgh pr status
Merge a PRgh pr merge 123
Create an issuegh issue create
List issuesgh issue list
Clone a repogh repo clone owner/repo
See workflow runsgh run list
Open repo in browsergh repo view --web

Resources