Skip to main content

Command referencegh pr diff

gh pr diff command (Linux & Windows / GitHub CLI)

Linux & WindowsGitHub CLIgitbeginner

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 / optionMeaning
--name-onlyShow only changed file names.
--patchOutput a patch format suitable for review tooling.
--colorControl 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`.

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.