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?
| Task | Browser Way | CLI Way |
|---|---|---|
| Create PR | Open browser → Navigate → Click buttons → Fill form | gh pr create |
| Check PR status | Open browser → Find PR → Read | gh pr status |
| View issue | Open browser → Navigate to issues | gh 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 CLI | Use Browser |
|---|---|
| Creating PRs | Complex PR reviews with many files |
| Quick status checks | Reading long discussions |
| Routine operations | Managing project boards |
| Scripting/automation | First-time repo setup |
Quick Reference
| I want to... | Command |
|---|---|
| Create a PR | gh pr create |
| See my PRs | gh pr status |
| Merge a PR | gh pr merge 123 |
| Create an issue | gh issue create |
| List issues | gh issue list |
| Clone a repo | gh repo clone owner/repo |
| See workflow runs | gh run list |
| Open repo in browser | gh repo view --web |