Command referencegh pr diff
gh pr diff command (Linux & Windows / GitHub CLI)
What it does
Show the diff for a pull request in the terminal. When people search for gh pr diff, 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.
Show the diff for a pull request in the terminal.
Syntax
gh pr diff [<number> | <url> | <branch>] [flags]
Common options
| Flag / option | Meaning |
|---|---|
| --name-only | Show only changed file names. |
| --patch | Output a patch format suitable for review tooling. |
| --color | Control colorized diff output. |
Practical examples
Diff current PR
gh pr diff
Prints the full diff for the PR on the current branch.
File list
gh pr diff 123 --name-only
Lists files changed in PR 123.
Specific PR
gh pr diff 123
Shows the patch for pull request 123.
Common mistakes
- Piping a huge diff without `--name-only` and flooding the terminal.
- Reviewing only the diff and skipping failing checks from `gh pr checks`.
Related commands
- gh pr viewDisplay pull request metadata, body, and checks in the terminal or browser.
- 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 pr checksShow GitHub Actions and status-check results for 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 diff do in GitHub CLI?
Show the diff for a pull request in the terminal.
Does gh pr diff 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 diff example?
Try `gh pr diff` — Prints the full diff for the PR on the current branch.
Do I need a token in the command line for gh pr diff?
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.