Skip to content

Diff and Checkout

Review pull request changes with local checkout and diff tooling.

Global options available on all PR commands: --json [fields], --jq <expression>, --no-color, -w, --workspace, -r, --repo.

Check out a pull request’s source branch locally.

Terminal window
bb pr checkout <id> [options]
Argument Description
id Pull request ID
Option Description
-w, --workspace <workspace> Workspace
-r, --repo <repo> Repository
--json Output as JSON
Terminal window
# Checkout PR #42 to review locally
bb pr checkout 42
# Checkout PR from specific repository
bb pr checkout 42 -w myworkspace -r myrepo

The command, in order:

  1. Fetches the latest changes from the remote
  2. Checks out the pull request’s source branch
  3. If that checkout fails, creates a local branch pr-<id> tracking origin/<source-branch>

--json returns { success, pullRequestId, branch, pullRequest }, where branch is whichever of the two names was checked out.


View the diff of a pull request in unified diff format.

Terminal window
bb pr diff [id] [options]
Argument Description
id Pull request ID (optional - auto-detects from current branch)
Option Description
-w, --workspace <workspace> Workspace
-r, --repo <repo> Repository
--color <when> Colorize output: auto, always, never (default: auto)
--name-only Show only names of changed files
--stat Show diffstat (files changed, insertions, deletions)
--web Open diff in web browser
--json Output as JSON
Terminal window
# View diff for PR #42
bb pr diff 42
# Auto-detect PR from current branch
bb pr diff
# Show only changed file names
bb pr diff 42 --name-only
# Show statistics (like git diff --stat)
bb pr diff 42 --stat
# Open diff in browser
bb pr diff 42 --web
# Return browser URL as JSON
bb pr diff 42 --web --json
# Disable colors for piping to file or other commands
bb pr diff 42 --color never > pr-42.patch
# Get diffstat as JSON for scripting
bb pr diff 42 --stat --json

--stat output:

src/index.ts | +12 -3
src/utils.ts | +4
docs/README.md | -8
3 files changed, 16 insertions(+), 11 deletions(-)
  • When no ID is provided, the command searches for an open pull request whose source branch matches your current git branch
  • --color auto colors the diff only when stdout is a terminal: green for additions, red for deletions, cyan for hunk headers. Whole lines are colored by their leading marker — there is no language-aware highlighting
  • --color never forces plain text, which is what you want when redirecting to a file or piping into another command. The global --no-color flag does the same for every command
  • The value is validated before the request. A typo fails with --color must be one of: auto, always, never plus a (Did you mean never?) suggestion, rather than silently falling back
  • Passing --color <when> at all turns the global color setting on, because the CLI resolves color by scanning raw argv for a --color token. bb pr diff 42 --color never still leaves the diff body uncolored, but it overrides --no-color and NO_COLOR for everything else that invocation prints. See Global Flags → Precedence summary
  • -w is the global short alias for --workspace. To open the diff in a browser you must spell out --web
  • For opening other Bitbucket pages (PR detail, files, commits, pipelines, settings) in the browser, see bb browse