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:
- Create a branch and make changes
git commitwith a descriptive messagegh pr create- this prompts for title and descriptiongh pr view --webto check how it looks and request reviewers- After reviews,
gh pr mergeto merge (though I usually use the web UI for this since I want to see the checks)
For reviewing PRs:
gh pr listto see what needs reviewgh pr checkout <number>to check out the PR locally- Test the changes, review the code
gh pr reviewto 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