Command referencegh pr view
gh pr view command (Linux & Windows / GitHub CLI)
What it does
Display pull request metadata, body, and checks in the terminal or browser. When people search for gh pr view, they usually want practical GitHub CLI flags, safe examples, and how this subcommand fits everyday PR and repo workflows on Linux, Windows, and macOS. Syntax, options, and copyable examples are below.
Display pull request metadata, body, and checks in the terminal or browser.
Syntax
gh pr view [<number> | <url> | <branch>] [flags]
Common options
| Flag / option | Meaning |
|---|---|
| -w, --web | Open the pull request in a browser. |
| -c, --comments | Include comments. |
| --json | Machine-readable field selection. |
Practical examples
Current branch PR
gh pr view
Shows the pull request associated with the checked-out branch.
By number
gh pr view 123
Prints details for PR 123.
Open web
gh pr view 123 -w
Opens the PR page for review in the browser.
Common mistakes
- Running `gh pr view` on a branch that has no open pull request.
- Confusing view with `gh pr diff`, which focuses on the patch.
Related commands
- gh pr diffShow the diff for a pull request in the terminal.
- gh pr statusShow pull request status relevant to your work: current branch, created PRs, and review requests.
- gh pr checkoutCheck out a pull request locally as a branch so you can build, test, or review the changes.
- gh pr reviewSubmit an approve, request-changes, or comment review on a pull request.
- gh auth loginAuthenticate the GitHub CLI with GitHub.com or GitHub Enterprise so other gh commands can run.
- gh pr createCreate a pull request from the current branch with title, body, reviewers, and base branch options.
- gh pr mergeMerge a pull request using merge commit, squash, or rebase strategies.
- gitTrack source history and collaborate through distributed repositories.
FAQ
What does gh pr view do in GitHub CLI?
Display pull request metadata, body, and checks in the terminal or browser.
Does gh pr view work on Windows and Linux?
Yes. The GitHub CLI (`gh`) runs on Linux, Windows, and macOS with the same subcommand syntax after you authenticate with `gh auth login`.
What is a practical gh pr view example?
Try `gh pr view` — Shows the pull request associated with the checked-out branch.
Do I need a token in the command line for gh pr view?
Prefer `gh auth login` so credentials stay in the system keyring or secure storage. Avoid pasting personal access tokens into shell history.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.