Using gh for PR work is much faster than the web UI, and allows staying in the terminal. It eliminates the need to constantly reach for the browser to check PR status, view diffs, or create new PRs.

View the current PR in browser:

gh pr view --web

Create a PR:

gh pr create

Create a PR against a specific base branch:

gh pr create --base main

View PR diff:

gh pr diff

Clone a repo:

gh repo clone owner/repo

View repo in browser:

gh repo view --web

The --web flag is your friend - it opens whatever you’re looking at in the browser.

My PR workflow Link to heading

Here’s my typical workflow when working on a feature:

  1. Create a branch and make changes
  2. git commit with a descriptive message
  3. gh pr create - this prompts for title and description
  4. gh pr view --web to check how it looks and request reviewers
  5. After reviews, gh pr merge to merge (though I usually use the web UI for this since I want to see the checks)

For reviewing PRs:

  1. gh pr list to see what needs review
  2. gh pr checkout <number> to check out the PR locally
  3. Test the changes, review the code
  4. gh pr review to submit my review with comments

The CLI is great for creating and checking PRs, but I still use the web UI for actual code review since the inline commenting experience is better there.

gh CLI vs hub Link to heading

Before gh, there was hub - another GitHub CLI wrapper. I used hub for years, but gh is the official GitHub CLI and it’s better in every way:

  • Better authentication (uses GitHub’s OAuth device flow)
  • More features (actions, releases, codespaces)
  • Actively maintained by GitHub
  • Better documentation

If you’re still using hub, switch to gh. The command syntax is similar, and migration is straightforward.

Other useful commands Link to heading

Check out a PR by number:

gh pr checkout 123

List your PRs:

gh pr list --author @me

Check PR status (checks, reviews):

gh pr status

View PR checks:

gh pr checks

Merge a PR:

gh pr merge --squash